Welcome to WebmasterWorld Guest from 54.226.189.112

Forum Moderators: not2easy

Message Too Old, No Replies

div content alignment

how to align div content to bottom of container box

     

KatrinR

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

5+ Year Member




Hello,

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>
</div>
</div>

here the css part:

#mcfooter_wedding{
width:700px;
clear:both; [...refers to other part of the layout...]
height:90px;
background-color:ffcccc;
margin:30px 0px 30px 0px;
}
#mcfooter_wedding #weddnav{float:left;
margin:0;padding:0;
height:100%;}
#mcfooter_wedding #weddnav .weddnav1{
float:left;
margin-left:40px;
vertical-align:bottom;
border:1px solid #000000;}

I appreciate your help!

Katrin

ratman7

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

5+ Year Member



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...

KatrinR

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

5+ Year Member



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,

Katrin

ratman7

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

5+ Year Member



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.

Xapti

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

WebmasterWorld Senior Member 5+ Year Member



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.

ratman7

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

5+ Year Member



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.

KatrinR

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

5+ Year Member



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.

Katrin

 

Featured Threads

Hot Threads This Week

Hot Threads This Month