Html 引导程序表单必填字段
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22954434/
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
bootstrap form required field
提问by lunr
I have a bootstrap form like this:
我有一个像这样的引导程序:
<div class="container">
<form class="form-horizontal">
<div class="form-group">
<div class="col-xs-2 text-right">
<label class="control-label">Name</label>
</div>
<div class="required col-xs-10" >
<input class="form-control" type="text" />
</div>
</div>
</form>
</div>
Now the name field is required so i want to display an asterisk right next to it. I tried this:
现在名称字段是必需的,所以我想在它旁边显示一个星号。我试过这个:
.required:after {
content: " *";
}
But it is displayed under the input, not right next to it. How can i fix this? JSFiddle: http://jsfiddle.net/Dc5yw/
但它显示在输入下方,而不是旁边。我怎样才能解决这个问题?JSFiddle:http: //jsfiddle.net/Dc5yw/
回答by James
回答by Abhijit Mali
check this fiddle.this will solve ur problem.
检查这个小提琴。这将解决你的问题。
change this
改变这个
<div class="required col-xs-10" >
<input class="form-control1" type="text" />
</div>
回答by T J
回答by Pravin Waychal
回答by Alex Ferrer
In your HTML
在你的 HTML
<div class="form-group required">
<label class="col-md-4 control-label" for="textinput">Name<span style="color:red;">*</span></label>
<div class="col-md-4">
<input id="textinput" name="textinput" placeholder="Your name" class="form-control input-md" required="" type="text">
</div>
</div>