[英]ML - CSS How to align correctly a 'required' asterisk before la form label with the label text?
I am adding a 'required' asterisk before a Bootstrap form label as following 我在Bootstrap表单标签之前添加“必需”星号,如下所示
The generated html bootstrap_form is the following 生成的html bootstrap_form如下
<div class="form-group-default input-group input-group-attached col-sm-12">
<div class="form-group">
<label class="required control-label" for="user_email">Adresse courriel</label>
<input class="form-control form-control" type="email" value="" name="user[email]" id="user_email">
</div>
<span class="input-group-btn">
<input type="submit" name="commit" value="Réinitialiser" class="btn btn-success btn-cons bold all-caps">
</span>
</div>
and my CSS entry is : 我的CSS条目是:
label.control-label.required:before {
color: red;
content: "*";
padding-top: 10px;
font-size: 20px;
font-family: arial;
}
I tried using padding-top to lower the asterisk at le level of the label text , bit now way ... how can I align it better ? 我尝试使用padding-top降低标签文本的星号,现在有点...如何更好地对齐它?
thanks for suggestions 谢谢你的建议
You should be able to control the position of the asterisk with position:relative
and top:...px
. 您应该能够使用
position:relative
和top:...px
来控制星号的position:relative
。
Something like : 就像是 :
label.control-label.required:before {
color: red;
content: "*";
font-size: 20px;
position:relative;
top:6px;
font-family: arial;
}
Try removing padding and add float: 尝试删除填充并添加浮点数:
<style>
label.control-label.required:before {
color: red;
content: "*";
float:left;
position:relative;
font-size: 20px;
font-family: arial;
}
</style>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.