Reputation: 11
Scenario:
I have a box (300px wide by 300px tall.) I have an unordered list within this box, which has four list items. Each item consists of a thumnail image (32X32), a link link directly to the right of the thumbnail and then a string of text that's on the next line beneath the link.
Notes:
Current implementation:
<ul>
<li><img class="thumb" src="baby.jpg"><a href="http://example.com" class="post-link">Post link title</a><br/>Date goes here</li>
<li>And again...</li>
<li>And again...</li>
<li>And again.</li>
</ul>
And for my CSS:
img .thumb {
float: left;
width: 32px;
height: 32px;
display: inline;
}
a .post-link {
float: left;
display: inline;
}
Currently, my image is on its own line, and then the text is beneath it. I'm tired and cranky -- and this is only one of many bugs. Help this poor, tired guy, will you?
Upvotes: 0
Views: 761
Reputation: 51
I think what you want like this.
<ul>
<li><div style="float:left;"><img class="thumb" src="baby.jpg"></div><a href="http://example.com" class="post-link">Post link title</a><br/>Date goes here</li>
<li>And again...</li>
<li>And again...</li>
<li>And again.</li>
</ul>
The CSS
img.thumb {
width: 32px;
height: 32px;
display: inline;
}
a .post-link {
display: inline;
}
Just wrap div inside the image with float inside. Others will adjust it itself
Upvotes: 0
Reputation: 1808
Just wrap the picture and text within a div
<ul>
<li><div><div><img class="thumb" src="baby.jpg"></div><a href="http://example.com" class="post-link">Post link title</a><br/>Date goes here</div></li>
<li>And again...</li>
<li>And again...</li>
<li>And again.</li>
</ul>
.thumb {
float: left;
width: 32px;
height: 32px;
display: inline;
}
.post-link {
float: left;
display: inline;
}
Fiddle (I used a black div to represent a picture, it should all work the same) : Fiddle
Upvotes: 0
Reputation: 3966
It should be img.thumb
- no space; or just plain .thumb
if you are only using it for the img
tags, same goes for the a.post-link
.
img.thumb
means you are targeting an img
element that has the class .thumb
.
img .thumb
means you are targeting elements with the .thumb
class that have parents that are img
elements.
Upvotes: 1