gpt4 book ai didi

javascript - 如何更改 Bootstrap 切换菜单中的文本对齐方式?

转载 作者:行者123 更新时间:2023-11-30 15:24:38 24 4
gpt4 key购买 nike

我想在 Bootstrap 页面的切换菜单中右对齐链接项,但它不起作用。顺便说一句,菜单在左边,标志在右边,但需要将元素向右对齐才能出现在标志下方。有帮助吗? this is the case 这是我的代码

<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="logo"><a href="#"><img src="img/logob.png" alt=""></a></div>
<div class="navbar-header">
<button type="button" class="navbar-toggle fl7" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>

</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li><a href="#">item 1</a></li>
<li><a href="#">item 2</a></li>
<li><a href="#">item 3</a></li>
<li><a href="#">item 4</a></li>
<li><a href="#">item 5</a></li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>

最佳答案

只需在 li 中为移动 View 添加 css text-align:right

@media (max-width:767px){
.nav>li{
text-align:right
}
}

.logo{
float:right;
padding:5px 0;
font-size:25px;
}


@media (max-width:767px){
.nav>li{
text-align:right
}
.navbar-inverse .navbar-toggle{
float:left;
margin-left:15px;
}
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<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-fixed-top" role="navigation">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="logo"><a href="#"><img src="img/logob.png" alt="">Logo</a></div>
<div class="navbar-header">
<button type="button" class="navbar-toggle fl7" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>

</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li><a href="#">item 1</a></li>
<li><a href="#">item 2</a></li>
<li><a href="#">item 3</a></li>
<li><a href="#">item 4</a></li>
<li><a href="#">item 5</a></li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>

关于javascript - 如何更改 Bootstrap 切换菜单中的文本对齐方式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43183454/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com