homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / CSS
Forum Library, Charter, Moderators: not2easy

CSS Forum

div content alignment
how to align div content to bottom of container box

 6:57 pm on Nov 30, 2007 (gmt 0)


I want to create a vertical navigation bar that is align at the bottom of the container box.
I tried it with vertical-align:bottom in the css, even tried to add valign="bottom" in the xhtml doc (what I really prefer to avoid), yet nothing works. Is it because of working with floats?

here is the code snippet

<div id="mcfooter_wedding">
<div id="weddnav">
<div class="weddnav1"><img src="images/wedding/weddvenuesm.jpg" /><br>venues</div>
<div class="weddnav1"><img src="images/wedding/weddworkshopsm.jpg" /><br>workshop</div>
<div class="weddnav1"><img src="images/wedding/weddmenusm.jpg" /><br>menus</div>
<div class="weddnav1"><img src="images/wedding/weddphotogsm.jpg" /><br>gallery</div>
<div class="weddnav1"><img src="images/wedding/weddindexsm.jpg" /><br>wedding home</div>
<div class="weddnav1"><img src="images/wedding/weddprepsm.jpg" /><br>planning</div>

here the css part:

clear:both; [...refers to other part of the layout...]
margin:30px 0px 30px 0px;
#mcfooter_wedding #weddnav{float:left;
#mcfooter_wedding #weddnav .weddnav1{
border:1px solid #000000;}

I appreciate your help!




 8:25 pm on Nov 30, 2007 (gmt 0)

You don't need to float #weddnav if it is wrapped in a div. It should appear oriented by default in the top left of the div it is contained in. Then put top margin or padding on #weddnav to get it positioned where you want. eg., margin-top:30px;
Hope that helps...


 9:42 pm on Nov 30, 2007 (gmt 0)

hi ratman7,

every link image has a different height, therefore, instead of having them all aligned on top (as it is by default), I thought there would be a possibility to simply *align* them all at the bottom.

Well, yes, if this is not possible, I could make the link images all the same height and define a top margin.

thank you for your reply,



 10:12 pm on Nov 30, 2007 (gmt 0)

No problem. You could try negative bottom margin values, or a define a different class for each nav item. Sizing things identically is probably your best bet though, it often seems to make things easier.


 11:28 pm on Nov 30, 2007 (gmt 0)

Vertical align (in the way you described) is for tables only. You could achieve that by using non-semantic markup (being tables) if you wanted.
I think something that would also work would be to use vertical-align, but only on images, no divs (and therefor no text). This is because vertical-align is assigned to inline elements, to which images are by default a part of.

Not only is it not really possible (properly) to control vertical alignment with the CURRENT specification of CSS, but even if it were, it would conflict with your float.

Vertical alignment without using tables can be accomplished either with hacks/workarounds (display:table-cell for browsers which support; hacks for IE) or javascript.


 11:34 pm on Nov 30, 2007 (gmt 0)

Not only is it not really possible (properly) to control vertical alignment with the CURRENT specification of CSS, but even if it were, it would conflict with your float.

True, since CSS offers other ways to position elements, vertical align isn't necessary.


 12:32 am on Dec 1, 2007 (gmt 0)

thank you,both!

Now, everything is clear to me.
No, I don't want to use tables, hacks are not necessare in that case, therefore, I will use the margin-top solution.


Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / CSS
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved