我在m网页上有一个引导导航栏,它的右侧有一个切换按钮。但是,当我单击它时,它向右移动10px,然后当它折叠时,向后移动。这看起来很奇怪。我尝试了margin:0 auto!important;在CSS中。但这使切换按钮的位置居中。我希望我的切换按钮显示在右侧,并且不应在单击时移动。
我在导航栏品牌和切换按钮之间添加了许多h3标签,以使切换按钮显示正确。因为它没有出现。
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<nav class="navbar navbar-expand-md navbar-light bg-light fixed-top navbar-collapse" style="position: fixed;">
<!--<a class="navbar-brand text-center w-100" href="#">Navbar</a>-->
<a href="#" class="navbar-brand"><img src="https://dummyimage.com/100x100/000/fff" height="50px" width="60px" style="align:center; position: fixed !important;"></a>
<button type="button" class="navbar-toggler navbar-right ml-auto" data-toggle="collapse" data-target="#navbarCollapse">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarCollapse">
<div class="navbar-nav">
<a href="#" class="nav-link active" style=" text-align: center;" ><h4><b>HOME</b></h4></a>
<a href="buy.html" class="nav-link button" style="text-align: center;"><h4><b>OPPURTUNITIES</b></h4></a>
<a href="advertise.html" class="nav-item nav-link" style=" text-align: center;"><h4><b>BECOME PARTNER</b></h4></a>
<a href="other.html" class="nav-item nav-link" style=" text-align: center;"><h4><b>OTHER PRODUCTS</b></h4></a>
<a href="#contactform" class="nav-item nav-link" style="text-align: center;"><h4><b>CONTACT</b></h4></a>
<div class="nav-link" style="text-align: center;"> <a href="https://www.facebook.com/pratham.notebook" ><i class="fab fa-facebook-square" ></i></a>
<a href="https://www.instagram.com/pratham.notebook"><i class="fab fa-instagram" ></i></a>
</div>
</div>
</div>
</nav>
答案 0 :(得分:0)
将此类CSS添加到您的代码中。
button.navbar-toggler {
float: right;
padding: 10px;
margin: 20px;
}