Vertical alignment in IE7

2019-05-10 02:57发布

问题:

I have used CSS to create a tableless layout. While this renders properly in IE8, FireFox and Chrome, it does not on IE7, which I expected. But I was wondering if there was any solution for vertical-align: middle;. This seems to be the core of my problem in IE7.

#main { 
    margin: 0 auto;
    height: 500px;
    display: table;
   position: relative;
}

#main ul {
    display: table-cell;
    vertical-align: middle;
    text-align:center;
}
#main ul li {
    display: inline-block;
    margin: 10px;
    border: 1px solid #d0dad2;
    height: 170px;  
}

<div id = "main">
    <ul> 
        <li><img src="images/test.jpg" alt="staff" /></li>
    </ul>
</div>

回答1:

Have a look at this tutorial by Chris Coyier: http://css-tricks.com/vertically-center-multi-lined-text/

Hope this helps.



标签: html css xhtml