I have a random layout issue — I’m still relatively new to web design and I’ve made way too much use of absolutely position layouts in the past and I’m trying to get away from it now. So here’s the situation:
I have a header that is fixed to the top. It has a height of 200px and a width of 100%. On the left side I have an image that I want to stay stuck to the left. On the right side is a horizontal nav UL. I want the image to stay put, and I want the nav to be centered in the remaining space on the right, adjusting as the browser is resized. This seems simple to me, but for some reason I can’t get it to work as I want.
Below is a screen shot — you can see that the nav is not centered:
This reply has been reported for inappropriate content.
Here is one way. Position fixed the nav. Give the nav a fixed width. Give it left 50% and a negative left margin equal to half the width of the nav. Then add back to the negative margin half the width of that left image.
Or another way. Say the left image is 300px wide. Set the nav to left 300px and right 0 and give it text align center. That’s prob the easiest but won’t work in ie6. To work in ie6 you’ll need to use percentage widths instead. 20% 80% and give the left image a min-width. Which will also need an ie6 hack.
Oops I stand corrected — I had left out a "px" after the left value of my ul, apologies!
While that does work it has the unfortunate side effect of collapsing vertically as the window resizes. I know this is because there is no fixed width on the UL, and adding one takes the centering away entirely. Is there any work around for this?