简体   繁体   English

Bootstrap导航栏宽度问题

[英]Bootstrap navbar width issue

I have annoying problem in my bootstrap menu, when I added " navbar Form" in the menu the width of the menu become larger than the width of the screen in mobile mode (when I decrease browser width for example, or when I open the page on the mobile). 我的引导程序菜单中有个烦人的问题,当我在菜单中添加“ navbar Form”时,菜单的宽度变得大于移动模式下的屏幕宽度(例如,当我减小浏览器宽度或打开页面时)在移动设备上)。 Knowing that the issue disappear whenever I remove the form code. 每当我删除表单代码后,问题都会消失。 See my code: 看我的代码:

 <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/> <li> <form class="navbar-form" role="search" action="ActionPages\\index_Search_Action.php" method="post" accept-charset="utf-8"> <div class="input-group"> <div class="input-group-addon" id="basic-addon1"><span class="glyphicon glyphicon-search" style="font-size:large"></span></div> <input type="text" name="txtSearch" class="form-control" placeholder="Search" aria-describedby="basic-addon1"> </div> </form> </li> 

What Should I do? 我该怎么办?

We would need to see the rest of the DOM for the nav bar that you used to fully know the issue, but you can try this, it should work: 我们需要查看导航栏的其余部分,您以前已经完全了解过该问题,但是可以尝试一下,它应该可以工作:

 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> <!-- Latest compiled and minified JavaScript --> <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> <nav class="navbar navbar-default"> <div class="container-fluid"> <!-- Brand and toggle get grouped for better mobile display --> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false"> <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 class="active"><a href="#">Link <span class="sr-only">(current)</span></a></li> <li><a href="#">Link</a></li> <li> <form class="navbar-form" role="search" action="ActionPages\\index_Search_Action.php" method="post" accept-charset="utf-8"> <div class="input-group"> <div class="input-group-addon" id="basic-addon1"><span class="glyphicon glyphicon-search" style="font-size:large"></span></div> <input type="text" name="txtSearch" class="form-control" placeholder="Search" aria-describedby="basic-addon1"> </div> </form> </li> </ul> </div> <!-- /.navbar-collapse --> </div> <!-- /.container-fluid --> </nav> 

Maybe try removing your <li> tags. 也许尝试删除您的<li>标签。 These tags are intended to be used inside some kind of list. 这些标记旨在在某种列表内使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM