Vertical Centering a block in IE7

后端 未结 4 464
滥情空心
滥情空心 2021-01-14 03:07

I\'m trying to get vertical centering a block in IE7 (IE6 if possible too), let me get one thing clear - I\'m not vertically centering the actual element, but the text with

4条回答
  •  礼貌的吻别
    2021-01-14 03:26

    This is a known bug. The way to fix this, which may not be applicable in your situation, is to add a Float to the element and have it display as inline-block to make hasLayout work in IE. I will also supply FF2 hacks to get around issues there too.

    Fixed code:

    a { 
        display: inline-block;
        display: -moz-inline-stack; /*FF2 Hack*/
        zoom: 1; /*IE inline-block star hack*/
        *display: inline; /*IE inline-block star hack*/
        float: left; 
        width: 100px;
        _height: 54px; /*FF2 Hack*/
        background: black;
        color: white;
        text-align: center; 
        text-decoration: none; 
        margin: 0px auto;
    }
    
    Hello superlongword 
    

    EDIT

    I didn't add a float, because I figured with the other hacks being used, it wouldn't matter.

提交回复
热议问题