When you apply positioning to an element, it will use the positioning available on it's parents. If none is provided, it will position to the body element. So when you position: absolute
to get the text/link at the bottom of the element, you have to position: relative
(or position: absolute
) one of it's parents, otherwise it won't know which you want it to position in relation to. Conversely, whichever it finds first, it will use that element to position against.
I think it's possible you've got too much markup to accomplish what you're doing here (what is the .placeholder
for? why not just use the li
?), and the span
s that wrap one of the blocks looks out of place (and should be a div
if you really need a wrapper there). And I'm not sure, but you might want to change #items
to a class, if you need to reuse it. It looks out of place as an id
. And your id and class names are not descriptive, and your selectors are not specific enough (generally, stay away from ul
and li
for styling specific parts of a page, as these have a global effect).
Nonetheless, I think this is what you're looking for. Note how I use padding
on #items li
, and then compensate bottom: 5px
. You also don't need to position the img
tag if it's just going to be at the top of the block, centered.
HTML (Fragment)
<li>
<div class="itemplaceholder">
<img src="http://www.els.qut.edu.au/blendedlearning/blackboard/graphics/test_on.gif"/>
<p>
Test title<br/>
Description A
<a href="#">Link</a>
</p>
</div>
</li>
CSS
#items {
display: inline;
position:relative;
margin: 0;
padding: 0;
}
#items li {
float: left;
list-style-type: none;
margin: 0;
padding: 5px 0 0 0;
}
#items .itemplaceholder {
height:200px;
width:160px;
text-align: center;
position: relative;
}
.placeholder {
width:640px;
height:200px;
overflow: hidden;
}
.content {
width:800px;
height:240px;
}
#items .itemplaceholder p {
position: absolute;
bottom: 5px;
width: 100%;
height: 50%;
}
#items .itemplaceholder p a {
position: absolute;
display: block;
bottom: 0;
text-align: center;
width: 100%;
}
http://jsfiddle.net/39bhW/3/