Firefox和IE6垂直居中

<html>
    <body>
        <div style="display: table-cell; vertical-align: middle; height: 200px; border: 1px solid red;">
            <p>垂直居中,Firefox only</p>
            <p>垂直居中,Firefox only</p>
            <p>垂直居中,Firefox only</p>
        </div>
        <div style="border: 1px solid red; height: 200px; position: relative;">
             <div style="position: absolute; top: 50%;">
                 <div style="position: relative; top: -50%;">
                     <p>垂直居中,IE6 only</p>
                     <p>垂直居中,IE6 only</p>
                     <p>垂直居中,IE6 only</p>
                 </div>
             </div>
        </div>
        <div style="border: 1px solid red; height: 200px; position: relative; display: table-cell; vertical-align: middle;">
             <div style="position: static !important; position: absolute; top: 50%;">
                 <div style="position: relative; top: -50%;">
                     <p>垂直居中,Firefox IE6 only</p>
                     <p>垂直居中,Firefox IE6 only</p>
                     <p>垂直居中,Firefox IE6 only</p>
                 </div>
             </div>
        </div>
    </body>
</html>

 

你可能感兴趣的:(html,firefox)