我在导航栏的左侧有徽标,在右侧的菜单按钮上是我想更改导航栏方向,以便徽标位于右侧,左侧的菜单按钮是我的代码,
<nav class="navbar navbar-inverse navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" rel="home" href="#" title="Buy Sell Rent Everyting">
<img style="max-width:100px; margin-top: -7px;"
src="./Styles/img/seha1.png">
</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li><a href="#">abc</a></li>
<li><a href="#">abc</a></li>
<li><a href="#">abc</a></li>
<li><a href="#">abc</a></li>
</ul>
</div>
</div>
</nav>
我尝试过使用该导航标签外侧的样式navbar pull right
的一种方法。并在按钮navbar pull left
上起作用,但会增加导航栏的宽度
希望获得您的建议
谢谢
答案 0 :(得分:0)
您是对的,下一个链接中提到的解决方案不适用于 Bootstrap 3 :
How to implement RTL bootstrap 4 navbar?
但是,我设法使用名为navbar-rtl
的自定义类解决了您的问题,该类将自定义导航栏的CSS
样式,使其外观为RTL
。我希望这可以为您提供帮助:
@media(min-width:768px) {
.navbar-rtl .navbar-header {
float: right;
}
}
.navbar-rtl .navbar-brand {
float: right;
}
.navbar-rtl .navbar-toggle {
float: left;
}
.navbar-rtl .navbar-nav {
float: right;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<nav class="navbar navbar-inverse navbar-default navbar-rtl">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" rel="home" href="#" title="Buy Sell Rent Everyting">
Navbar
</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li><a href="#">abc</a></li>
<li><a href="#">abc</a></li>
<li><a href="#">abc</a></li>
<li><a href="#">abc</a></li>
</ul>
</div>
</div>
</nav>