Interview Questions

How do I centre my page?

CSS Interview Questions and Questions


(Continued from previous question...)

93. How do I centre my page?

This is very easy. If we take the code in the last question and change it to this :
CSS
body, html {
height:100%;
}
body {
margin:0;
padding:0;
}
#wrap {
position:relative;
width:780px;
margin:auto; min-height:100%;
}
* html #wrap {
height:100%;
}

you get a page that fits an 800x600 resolution screen without a horizontal scrollbar, which will be centred at higher resolutions.

(Continued on next question...)

Other Interview Questions