Give help. Get help.

  • # April 23, 2010 at 9:30 am

    Hi all,

    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:


    Any help would be much appreciated!


    # April 23, 2010 at 4:39 pm

    Posting the css and a link to the file would elicit more responses…. :shock:

    # April 23, 2010 at 5:26 pm

    Was hoping the description would be enough, all of my attempts failed miserably. Here’s one:

    And here is the CSS I used (HTML is in the post above):

    * { margin: 0; padding: 0; }

    html,body { background-image: url(“../images/back-canyons.jpg”); background-attachment: fixed;
    background-repeat: no-repeat; background-color: black; }

    /* Layout */

    div#mast { position: fixed; top: 0px; left: 0px; width: 100%; height: 200px;
    background-image: url(“../images/back-gradient.png”); background-attachment: fixed;
    background-repeat: repeat-x; }

    div#mast-left { float: left; width: 301px; height: 278px; }
    div#mast-right { position: absolute; top: 0px; padding-left: 301px; width: 100%; }

    #mast-nav { margin: 0 auto; width: 706px; height: 51px; list-style-type: none; }
    #mast-nav li { display: inline-block; padding-right: 5px; /* IE 7 */ zoom: 1; *display: inline;}

    That almost does what I want, but the centering is off by 301 pixels to the right because of the fixed image on the left.

    # April 23, 2010 at 8:09 pm

    The problem with both of those is that as the browser width shrinks the nav begins to overlap the image. My goal is to have it stop shifting left as soon as it reaches the image.

    # April 24, 2010 at 10:19 am

    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?

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.