开发者

Can I add css style to this •?

Can I write some style css code for every • code I use in m开发者_运维问答y page, for example font-size: 16px;? Thanks.


No, you cannot. You cannot style text content, no matter how it’s encoded (either as direct characters or as entities).

The closest thing you can do is put <span class="bullet">•</span> into the document and style the class bullet.


Others have answered the main question; you cannot specify a CSS Rule based on text content (just on HTML elements, classes, and ids).

What you could do is use Javascript, or server-side rendering to do a .Replace() to wrap the character with the necessary HTML tags (replace just the character with a wrapped version of the character).


Here's a quick proof-of-concept; it could easily avoid the jQuery (it's a crutch of mine), and you might play around a bit with how the character is encoded in the Javascript (I had to copy/paste it in to work).

The key portion is:

.replace("•","<span class='bullet'>•</span>")


No. With CSS you can only address elements but not certain characters (ok, there are exceptions like :first-letter). You would need to put it into an element like span:

<span class="bullet">&#8226;</span>

Then you can use the selector span.bullet to style these elements:

span.bullet {
    font-size: 16px;
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜