Reputation: 10097
I'm trying to align an image with some text within a list item. I had previously asked a similar question but the solution(s) appeared to present a new challenge and I wanted to include an image to show what was going wrong.
How can I get the text and image to align in my list and prevent this (see image) diagonal behaviour from occurring?
Markup:
<div class="col-md-3">
<ul class="nav">
<li><%= link_to "Connect", "#", class: "footer-heading" %></li>
<li><%= image_tag "facebook.png", size: "32"%><%= link_to "Facebook", "url" %></li>
<li><%= image_tag "facebook.png", size: "32"%><%= link_to "Facebook", "url" %></li>
<li><%= image_tag "facebook.png", size: "32"%><%= link_to "Facebook", "url" %></li>
</ul>
</div>
CSS:
li img{
float: left;
}
With the current CSS I am getting this effect:
Upvotes: 1
Views: 58
Reputation: 28417
I assume that you are looking for a vertical list but which is neatly aligned left. Isn't it?
You can do away with img
tags and use backgrounds on li
.
Fiddle: http://jsfiddle.net/V2Zxb/
Give a class to your anchors, and use left padding to offset the logos:
a.fb {
background-image: url(facebook.png);
background-position: top left;
background-repeat: no-repeat;
line-height: 36px;
display: inline-block;
padding-left: 36px;
}
Upvotes: 0
Reputation: 362640
Use Bootstrap list-inline
..
<div class="col-md-3">
<ul class="list-inline">
<li>-</li>
<li>-</li>
<li>-</li>
</ul>
</div>
Upvotes: 0