No replies
gidmeister's picture
Last seen: 6 years 2 weeks ago
Timezone: GMT-4
Joined: 2011-03-01
Posts: 47
Points: 93

I have a logo and a menu that both have to be centered. But, due to the way my website is made, they have to have the 'absolute' positioning attribute.
Currently I do center them. I use javascript to get the monitor width, then I subtract their width and divide by 2. Then I set their 'left' css attribute to that number.

However, there is a disadvantage with doing that. On Internet Explorer 8 (I'm not sure about 9), you see the logo and the menu at the left side of the screen, and then gradually the javascript kicks in, and they move to the center.

On other browsers, the logo and the menu appear at the center without any of this problem.

So - is there a CSS method to center things, even when they have the absolute attribute?