Add an image to Bootstrap Navbar Links
source link: https://www.codesd.com/item/add-an-image-to-bootstrap-navbar-links.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Add an image to Bootstrap Navbar Links
I want to add a small avatar next to a link in my bootstrap navbar like this:
I am trying to add my image inside the <a>
tags of the link, but this is pushing the link out of line with the other links, because the image is taller than the text of the links.
Here is my HTML
<li><a href="link">
<img class="hidden-xs" src="img">
MIKE
</a>
</li>
Is there a proper way to easily add images to bootstrap nav-bars so that all the links still remain in line?
Here's @press' fiddle with the line height changed. You can obviously tweek around padding etc.. to your likes http://jsfiddle.net/c6f1ecrv/4/
.navbar-nav li a {
line-height:3em;
padding:5px 10px;
}
Related Articles
Float Bootstrap navbar links to the left on the mobile and on the desktop
The Bootstrap navbar link does not work
Broken Bootstrap Navbar Links
How do I add the image to the bootstrap popover?
How to add an image to an asp.net link button programmatically
navbar bootstrap active link
Add an image to a link based on its content
How to make Twitter Bootstrap Navbar transparent?
Bootstrap navbar transparent
Responsive Bootstrap Navbar
bootstrap navbar collapses social icons on top of each other
Bootstrap navbar search icon
Problem Bootstrap Navbar css
Add the image of the icon to the css class for the html elements
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK