CSS 如何使用 Twitter Bootstrap 在同一行中显示标签和文本框
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14433798/
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
How to show a label and text box in a same row using Twitter Bootstrap
提问by Wishnu
<div class="control-group">
<label for="name" class="control-label"><p class="text-info">Name <i class="icon-star"></i></p></label>
<div class="controls">
<input type="text" id="name" placeholder="Enter your name" class="span3">
</div>
this is not working for me, I dont wanna use 'form-horizontal' class or a table for this. I have tried with row and row-fluid class but its not working.
这对我不起作用,我不想为此使用“表单水平”类或表格。我已经尝试过 row 和 row-fluid 类,但它不起作用。
回答by Arun P Johny
You can wrap your code with <div class="form-horizontal">
. You don't need to have a form
to use form-horizontal
.
您可以使用<div class="form-horizontal">
. 你不需要有一个form
来使用form-horizontal
。
示例:
<div class="form-horizontal">
<div class="control-group row-fluid form-inline">
<label for="name" class="control-label"><p class="text-info">Name <i class="icon-star"></i></p></label>
<div class="controls">
<input type="text" id="name" placeholder="Enter your name" class="span3">
</div>
</div>
</div>
回答by Sandeep
You want horizontal form layout. This can be achieved by wrappping your code between a div having class as form-horizontal.
您需要水平表单布局。这可以通过将您的代码包装在一个类为表单水平的 div 之间来实现。
<div class="form-horizontal">
<div class="control-group">
<label for="name" class="control-label"><p class="text-info">Name <i class="icon-star"></i></p></label>
<div class="controls">
<input type="text" id="name" placeholder="Enter your name" class="span3">
</div>
</div>
To learn more click here
要了解更多信息,请单击此处