Twitter bootstrap 水平形式-设置控件标签宽度的最佳方法?
我是twitter引导的新手,我正在使用水平表单。我的代码是这样的:Twitter bootstrap 水平形式-设置控件标签宽度的最佳方法?,twitter-bootstrap,Twitter Bootstrap,我是twitter引导的新手,我正在使用水平表单。我的代码是这样的: <form class="form-horizontal"> <div class="control-group"> <label class="control-label" for="whatever">Whatever</label> <div class="controls"> <select
<form class="form-horizontal">
<div class="control-group">
<label class="control-label" for="whatever">Whatever</label>
<div class="controls">
<select id="whatever" name="whatever">
<option value="blah">Blah</option>
</select>
</div>
</div>
<div class="control-group">
<label class="control-label" for="another">Another</label>
<div class="controls">
<select id="something" name="something">
<option value="MyEntry">MyEntry</option>
</select>
</div>
</div>
<button type="submit" class="btn">Search</button>
</form>
无论什么
废话
另一个
迈entry
搜寻
当我这样做时,表格看起来很好。唯一的问题是控件标签的长度太长了,所以在标签的左边有很多空白。有没有办法缩短标签,这样我就不会有那么多的空白
谢谢。我创建了两个额外的表单类,并根据需要使用它们 这是我的css:
.form-small .control-label {
width: 100px;
}
.form-small .controls {
margin-left: 120px;
}
.form-medium .control-label {
width: 180px;
}
.form-medium .controls {
margin-left: 200px;
}
.form-xlarge .control-label {
width: 240px;
}
.form-xlarge .controls {
margin-left: 260px;
}
因此,如果我需要小标签:
<form class="form-horizontal form-small">
<!-- form body -->
</form>
当然,您可以根据需要设置自己的。控件标签
和。控件
宽度
希望有帮助
<form class="form-inline"
ng-submit="addCategory(transaction, categoryText)"
style='display:inline;'>
<span class="span2">
<label style='display:inline; width:140px'>{{param}}</label>
</span>
<input type="text" ng-model="categoryText" size="20" placeholder="add category">
</form>
{{param}}
我通常在“span”元素中跨越需要固定大小的元素,但这是为了生成重复表单尝试使用创建容器:
<div class="set_inline_block_class_selector">
<label>
<input type="radio" name="example_radio">Bootstrap radio button with controlled label
</label>
</div>
<style>
.set_inline_block_class_selector label{
display: inline-block;
}
</style>
带受控标签的引导单选按钮
.set_inline_block_class_选择器标签{
显示:内联块;
}
太棒了。这起作用了。我试着专门为控件标签本身添加我自己的类,但它不起作用。我不知道为什么。这样做效果很好。可能是一些愚蠢的CSS缓存问题或是一些奇怪的问题。非常好的解决方案!我已经为自己调整了宽度,效果非常好,谢谢!硬编码尺寸在手机和平板电脑上是如何工作的?似乎这会破坏bootstrap的响应能力。@Acyra对于移动支持,您应该进行媒体查询并使用width:100%