FirefoxとIE 6は垂直中央

1552 ワード

<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>