Can I dynamically ensure that the content always remains centered in the window pane on this website?
Right now it uses a static margin-left on the .items class, and it uses jquery tools.
/
Can I do it in just CSS or CSS and Javascript?
Thanks,
Kory
Can I dynamically ensure that the content always remains centered in the window pane on this website?
Right now it uses a static margin-left on the .items class, and it uses jquery tools.
http://andstones.ca/newsite/
Can I do it in just CSS or CSS and Javascript?
Thanks,
Kory
Share Improve this question asked Jun 14, 2010 at 20:51 KoryKory 3984 silver badges14 bronze badges3 Answers
Reset to default 4I didn't quite see what part you were talking about as it looks like most of it works just fine.
For auto-centering, you should use auto for margins:
margin: 0 auto;
Put that one whatever div you want centered.
Lets say that you want to center a container with 900px wide, the most cross browser way that I've used is:
div#container{
width:900px;
position:relative;
left:50%;
margin-left:-450px;
}
This goes to the center of the x axis and stays there regardless of other elements of that page! Of course that this only works with a fixed width and not a dynamic one!
If i remember correctly, you have to use the following in IE
text-align: center;
Even to center a div