开发者

css technique to apply to a character within a matching tag

开发者 https://www.devze.com 2023-03-14 16:11 出处:网络
Given I have the following tag: <label>Hello world *&l开发者_开发技巧t;/label> Is there a way to apply a css to the \"*\" in all label tags?In order you want to add anything after your lab

Given I have the following tag:

<label>Hello world *&l开发者_开发技巧t;/label>

Is there a way to apply a css to the "*" in all label tags?


In order you want to add anything after your label-element you could also use the following pseudo-element:

label:after {
   content: "*";
}


To style the *, you must wrap it in something:

<label>Hello world <span>*</span></label>

The CSS is simple:

label span {
    color: red
}

If you don't need to support older versions of IE, then go with @Dude's answer.


Try putting it in a span with a class, yes just the *.


Since you can't style plain text, the common technique is just to put what you want in a span and give the span a name/id/class.

You can also do this inline with:

<label>Hello world <span style="position:absolute;font-family:blah">*</span></label>
0

精彩评论

暂无评论...
验证码 换一张
取 消