开发者

css { content: "text"}, how do I add tags?

I wrote some dummy css. Instead of a tag I got escaped characters. How can I add a div tag instead?

.HeaderName:after{
content: "<div class=\开发者_如何学JAVA"Name2\">text</div>";
}

.Name2 {
color: red;
}


The content declaration cannot add tags to the page (tags are structural); additionally, CSS is meant for presentation changes, not structural content changes.

Consider using jQuery, instead, such as:

$(".HeaderName").after("your html here");


If you need that extra tag only to make the added text red, just do this:

.HeaderName:after{
    content: "text";
    color:red;
}

Tested on Chrome.


You can't insert tags using content: in CSS. Here is the relevant part of the spec; see the 'content' property in the CSS 2.1 spec.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜