将Asterisk添加到<label>的末尾

may*_*yrs 4 html css forms

是否可以在文本字符串的末尾添加星号<label>

这就是我所拥有的,但星号(当然)显示在整个标签后面:

<label class="xy-form-label-required" for="zipcode">
   Zip Code
   <span class="xy-form-labelinfo">
       Allowed characters a-z A-z 0-9 ,.-
       Could also be an information about the field...
   </span>
</label>
Run Code Online (Sandbox Code Playgroud)

我的CSS代码:

form.xy-form .xy-form-label-required:after {
    color: grey;
    content: ' *';
}
Run Code Online (Sandbox Code Playgroud)

这是结果:

邮政编码
允许的字符az Az 0-9,.-
*

这是我想要在不改变html标记的情况下实现的.

邮政编码*
允许的字符az Az 0-9,.-

Amy*_*yth 5

您只需添加以下CSS代码即可

.xy-form-label-required > span.xy-form-labelinfo:before{
  color: grey;
  content: " *";
}
Run Code Online (Sandbox Code Playgroud)