宽度不定 高度不定div 垂直居中 要求兼容ie8 只用css


我被sofish大神御人术送了出去 就是如题问题 我就是不知道ie8怎么办 所以没答得。
求各位大神告知

css

消逝的热情 9 years, 11 months ago

<body>


</body>

div {
width:500px;
height:800px;
margin-top:50%;
margin-left:50%;
top:-400px; //height的一半
left:-250px; //width的一半
}

tyrion answered 9 years, 11 months ago

display:table

永远的HIME answered 9 years, 11 months ago

好吧 我找到一种我觉得不错的


 .con-ghost {
    text-align: center;
    white-space: normal;
}

.con-ghost:before {
    content: '';
    display: inline-block;
    height: 100%;
    vertical-align: middle;
    margin-right: -0.25em;
}

.con-ghost {
    .box {
        display: inline-block;
        vertical-align: middle;
    }
}

暴走鹿鹿鹿 answered 9 years, 11 months ago

七旬D上弦月 answered 9 years, 11 months ago

海呀好气啊 answered 9 years, 11 months ago

Your Answer