List Items Middle Vertically Aligned

限于喜欢 提交于 2019-12-04 23:11:51

If you add a <div> inside the <li> and make the following changes to the CSS, it seems to work:

li {
    min-height : 45px;
    border-bottom : 1px black solid;
}
li div {
    height:45px;
    display:table-cell;
    vertical-align : middle;
}

See it live here-- works in IE8 and FF4: http://jsfiddle.net/RrVBh/

Ahh, good ol' vertical align. The easiest way is to set line-height: 45px; but this only works when you have one line of content and will force any additional lines to overflow.

Otherwise, you could use display:table-cell; vertical-align: middle; as demonstrated in the above link.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!