twitter-bootstrap 增加 Bootstrap 导航栏搜索表单宽度
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30511315/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Increasing Bootstrap navbar search form width
提问by user3383616
This is only the second time I've used stackoverflow so please forgive me if I make any mistakes.
这只是我第二次使用 stackoverflow,所以如果我犯了任何错误,请原谅我。
I'm having an issue increasing the width of the default Bootstrap navbar search form. I have tried some of the solutions I've seen on stackoverflow, however nothing seems to work.
我在增加默认 Bootstrap 导航栏搜索表单的宽度时遇到问题。我已经尝试了我在 stackoverflow 上看到的一些解决方案,但似乎没有任何效果。
Please see: http://jsfiddle.net/94zkLh8j/1/
请参阅:http: //jsfiddle.net/94zkLh8j/1/
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" class="read-more" 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>
<a class="navbar-brand" href="#">Vouchipster</a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<form class="navbar-form navbar-right" role="search">
<div class="form-group">
<div style="display:table;" class="input-group">
<input type="text" class="form-control" placeholder="Search for retailers, categories or products">
<span class="input-group-btn">
<button class="btn btn-green" type="button"><i class="fa fa-search"></i></button>
</span>
</div>
</div>
</form>
</div>
</div>
</nav>
回答by Brino
You can set the width of the inputelement in your document stylesheet. Use !importantto override any bootstrap widths. I recommend adding an id to the form for easy selection in css
您可以input在文档样式表中设置元素的宽度。使用!important覆盖任何引导宽度。我建议在表单中添加一个 id 以便于在 css 中选择
HTML
HTML
...
<form class="navbar-form navbar-right" role="search" id="navBarSearchForm">
...
CSS
CSS
<style>
#navBarSearchForm input[type=text]{width:430px !important;}
</style>

