[英]how to show asterisk sign before label start when label has fixed width
I want to show asterisk sign before my label indicating it is a mandatory field.我想在我的标签前显示星号,表明它是必填字段。 following is my css id code for label,以下是我的标签 css id 代码,
#label{
float: left;
height: 30px;
padding-right: 4px;
padding-top: 2px;
position: relative;
text-align: right;
vertical-align: middle;
width: 73px;
}
output of above is, * Label but I want it to be like, *Label Thanks上面的输出是,* 标签,但我希望它像,*标签谢谢
Use :before pseudo class使用 :before 伪类
.label:before{
content:"*" ;
color:red
}
Or要么
#req:before{
content:"*" ;
color:red
}
Without seeing the HTML it is difficult for us to know what is going on.如果没有看到 HTML,我们很难知道发生了什么。 I suspect you will be able to solve your problem using the little-known white-space
property, if the asterisk is in the same element as #label.如果星号与#label 位于同一元素中,我怀疑您将能够使用鲜为人知white-space
属性来解决您的问题。 Try using white-space: pre
.尝试使用white-space: pre
。
Here is some more info: http://www.w3schools.com/cssref/pr_text_white-space.asp以下是更多信息: http : //www.w3schools.com/cssref/pr_text_white-space.asp
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.