tags:

views:

55

answers:

4

I have the following HTML markup and I want the menu div tag to always be 5px away from the bottom border of the parent container.

I can manually through trial and error position it using margin-top, but if I were to change the logo or modify the div size I'd have to change this value again using trial and error. A much better solution would to tell if to always be 5px away from the bottom instead of telling it to be X pixels from the top.

Why doesn't this work though? alt text

<body>
    <div id="header">
        <img src="../../Content/images/cumaviLogo.png" alt="Cumavi.com - Compras y ventas online en Bolivia!" />    
        <ol id="topuserbar">
            <li>Bienvenidos, <span class="userSalute">Sergio!</span></li>
            <li><a href="#">Mis Anuncios</a></li>
            <li><a href="#">Perfil</a></li>
            <li><a href="#">Cerrar Sesion</a></li>
        </ol>
    </div>

    <asp:ContentPlaceHolder ID="MainContent" runat="server" />
</body>

#header
{
    background-image: url('images/headerBackground.png');
    background-repeat:repeat;
    width:auto;
}

#topuserbar
{
    border: 1px solid red;  
    font-family:Georgia;
    font-size:large;
    float:right;
    margin-top:45px;  
}

#topuserbar ol
{
}

#topuserbar li
{
    display:inline;
    margin-left:10px;
    color:#fff;
}
A: 

you are using ol which is a list ... therefore it has it's own margin and padding pre-set so that could play a big role on the outcome.

also you can use position: absolute for the menu on you css. and position: relative for your parent element. and then use bottom: 5px; for your menu. that will always stick the menu 5px to the parent which i presume it's what you are looking for.

also like i said check that ol tag margin and padding have been removed.

Val
A: 

Well, I allways encourage people to use a reset.css file http://meyerweb.com/eric/tools/css/reset/

And why ol? I think ul makes more sense in a menu like that...

Claudiu
A: 

Getting HTML elements to stay on the bottom of things is notoriously difficult. However, you could try moving the ol outside the header div, setting the position to relative and pulling its top up -Ypx.

The image size may change, but you can rest relatively assured that the the position of the ol relative to the div won't change.

This will be a little strange for the rest of your DOM flow though, unless you set the bottom margin of the ol to -Ypx as well.

Not really an answer ... but it may help.

fordareh
ever tried that on ie? -Ypx is evil. He's better of with absolute positioning than that.
Claudiu