我无法在导航栏的右侧对齐图像。
你能告诉我为什么吗?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>
答案 0 :(得分:2)
将 pull-right
类添加到您的图片中,它会正确对齐图片。
<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>
答案 1 :(得分:0)
.nav>li {
text-align:right;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" >
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.js"></script>
<script src="/Dashboard/js/indexscript.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 src="https://cdn.pixabay.com/photo/2017/02/16/10/20/target-2070972_960_720.png" width="10%" id="eye" ></li>
</ul>
</div>
</nav>
只需将text-align:right
添加到li Ypu就可以在小提琴和下面的片段中查看
答案 2 :(得分:0)
因为小提琴输出窗口太小。<div class="container">
<img src="http://via.placeholder.com/350x150" alt="about img 2" class="img">
<div class="overlay">
</div>
</div>
仅在float:left
时才会添加到navbar-right
。您可以扩展小提琴输出窗口的宽度以验证这一点。
答案 3 :(得分:0)
这可能与不关闭img标签或布局有关。我关闭了img标签并编辑了缩进,它工作正常。尝试这样的事情:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" >
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.js"></script>
<script src="/Dashboard/js/indexscript.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 src="https://cdn.pixabay.com/photo/2017/02/16/10/20/target-2070972_960_720.png" width="10%" id="eye" />
</li>
</ul>
</div>
</nav>