tags:

views:

58

answers:

2

I want to do this without javascript.

I can't figure out how to make all li with class "item" align to the bottom of the div#recent. Basically, every li is 192px wide. The problem is that each product image is a different height, so if one is only 40px tall, the text is at a different position than the one next to it.

<div id="recent">
<h2>Recent Items</h2>
<ul>
    <li class="item">
        <img src="images/product1.png" />
        <a href="#">
            Product Name Here<br/>
            Brand Name Here
        </a>
        <p>$182.32</p>
    </li>
</ul>
</div>

Any ideas?

A: 

Have you tried using CSS? On your div, set vertical-align:bottom, and set line-height & height to the same value?

TheGeekYouNeed
A: 

Wrap your images in there own container (like another div) and give that container a specific height.

<div id="recent"> 
<h2>Recent Items</h2> 
<ul> 
    <li class="item"> 
        <div class = "img_wrapper"><img src="images/product1.png" /></div>
        <a href="#"> 
            Product Name Here<br/> 
            Brand Name Here 
        </a> 
        <p>$182.32</p> 
    </li> 
</ul> 
</div> 

In your css, give .img_wrapper a height of 50px or whatever.

Levi Hackwith
The problem is that even if I have the same height for all of them, the image stays at the top of the section. All the words (Product Name, etc.) line up perfectly, but short images look weird because there's so much space between the bottom of the image and the top of the product name. What else should I try?
Matthew
can you post a link to an example of the problem?
Levi Hackwith
I don't have it online (developing on my local computer). I figured out I can anchor it to the bottom using position: absolute and bottom: 0, but left and right gets weird (images are different sizes). I might just have to use tables (I know that's a big NO) but I don't know what else to do.
Matthew
@matthewsteiner: You have my permission to use a table for this. You're right, it's not semantically correct, but neither is Google or Yahoo (or even this site) for that matter. Solve it with a table, and go home early.
Robert Harvey