Center single- AND multi-line li text vertically

后端 未结 2 752
南笙
南笙 2021-01-31 05:36

I have an unordered list with a background-image set. All list-items have the same height, the background-image is positioned left center.

The text of each item should b

2条回答
  •  佛祖请我去吃肉
    2021-01-31 06:09

    this is a most crossbrowser solution

        li {
        	width           : 200px;
            line-height     : 100px;
            height          : 100px;
        	border          : 1px blue solid;        
        }
        li span {
        	display				: -moz-inline-box;  /* FF2 or lower */
        	display				: inline-block;     /* FF3, Opera, Safari */
            line-height         : normal;
            vertical-align      : middle;    
        }
        
        li span		{ *display	: inline;} /* haslayout for IE6/7 */
    • My text
    • My longer text
    • My text, but this time is really wide
    • My text, some thoughts about how much it will expand in this item.

    I used star hack for brevity, you should avoid. Just use html5boilerplate solution, it uses conditional comments on body tag

提交回复
热议问题