tags:

views:

118

answers:

3

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

+1  A: 

I 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.

Kerry
Doesn't seem to work in chrome?
Kory
Seemed to work fine for me
Kerry
A: 

If i remember correctly, you have to use the following in IE

text-align: center;

Even to center a div

Chief17
I don't think its a must but I think it helps in certain circumstances
Kerry
A: 

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!

Zuul
That's a hacky one!
Humberto
@Humberto, and works just fine ;) W3C approved and all off that crap ;)
Zuul
I can't seem to get it work in chrome, the content div margin is still off, but it works in firefox and safari?
Kory
@korymath, It work for all browsers ;) But beware, it may be influencied by other style's that you have!! Since it's relative, it will be positioned relatively to it's containing element! Can you post your code ?
Zuul
This was a great snippet, which I still use. Thank you!
Kory