i have the "main" div here : http://tallevi.net/daniel/?page_id=5 if i change the screen resolution the div is not in the middle, currently the css of the "main" div is :
.#main {
width: 680px;
position: absolute;
right: 35%;
padding: 0 40px 5px 40px;
font: normal 14px Verdana, Arial, sans-serif;
line-height: 20px;
display: inline-block;
z-index: 2;
background: url(images/content_back.png) repeat-y;
}
wha'ts wrong?
The best way to centre an element is using margin: 0 auto;, try changing your code to:
#main {
width: 680px;
margin: 0 auto;
padding: 0 40px 5px 40px;
font: normal 14px Verdana, Arial, sans-serif;
line-height: 20px;
z-index: 2;
background: url(images/content_back.png) repeat-y;
}
Margin: 0 auto sets an "automatic" margin for the right and left, essentially centering it. (This only works if you specify a set width, which you have)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With