开发者

For some reason, margin: 0 auto isn't working (height isn't infinite)

http://talk.thegoodhumor.com/

As you can 开发者_如何学Gosee here, the height just isn't continuous and I have no idea why.

I've toyed with it for quite a while now, and I am still baffled.


First of all , margin: 0 auto; is used to center elements , it is also not possible to make a page with infinite height , but you can maximize it's height by using

.body{
    text-align:center; /* IE Center trick because margin:0 auto; will not work. Go go IE! :D */
}

.wrapper{
    min-height: 1080px;
    height: 1080px;
    width: 100%;
    /* DO NOT RESTORE THE ALIGNMENT HERE --- */
}

.wrapper .div {
    margin:0 auto; /*center the elements */
    text-align: left; /* restore the alignment */
    min-height: 100%; /* maximize the height; make it 1080 pixels */
    height: 100%; /* not necessary but i like to add it as well :) */
}

margin: 0 auto; 0 means that there will be 0 space between the division and the element thats right above it and auto will adjust the right spacing to be the same with the left one :)

It goes like this margin: top right bottom left;

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜