Home › Forums › CSS › Help centering a div › Re: Help centering a div
November 24, 2010 at 12:41 pm
#72393
Participant
Figured it out. My top answer wasn’t quite right when I tried it. But, then I remembered an article I read about how to center unordered lists in a nav when you don’t know their width. This is pretty much the same thing.
First I wrap my main div in another div, which I fix to the top. I then put left:50% on it. Then on my main div I make position relative and put left:-50% on it. And that centers it no matter what the width is.