greencucumber1 greencucumber1 - 24 days ago 5
CSS Question

Bootstrap align image in nav bar right

I'm unable to align an image on the right side of the nav bar.

Can you tell me why?

https://jsfiddle.net/2juzLktc/

<nav class="navbar navbar-inverse navbar-light">
<div class="container-fluid" id="div1">
<a class="navbar-brand" href="#"><img src="http://www.clker.com/cliparts/T/G/b/7/r/A/red-dot-hi.png" width="150px" height="30px"></a>
<ul class="nav navbar-nav navbar-right">
<li><img src="https://cdn.pixabay.com/photo/2017/02/16/10/20/target-2070972_960_720.png" width="10%" id="eye" ></li>
</ul>
</div>



Answer Source

Add pull-right class to your image like this and it will right align the image.

<ul class="nav navbar-nav navbar-right">
    <li><img class="pull-right" src="https://cdn.pixabay.com/photo/2017/02/16/10/20/target-2070972_960_720.png" width="10%" id="eye" ></li>
</ul>

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<nav class="navbar navbar-inverse navbar-light">
	<div class="container-fluid" id="div1">
	 <a class="navbar-brand" href="#"><img src="http://www.clker.com/cliparts/T/G/b/7/r/A/red-dot-hi.png" width="150px" height="30px"></a>
		<ul class="nav navbar-nav navbar-right">
		<li><img class="pull-right" src="https://cdn.pixabay.com/photo/2017/02/16/10/20/target-2070972_960_720.png" width="10%" id="eye" ></li>
		</ul>
	</div>
</nav>