CSS内容属性未显示 [英] CSS content property not displaying
本文介绍了CSS内容属性未显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是CSS的新手,并且正在关注一个图书示例:
I am new to CSS and I'm following a book example:
我从本书中复制了以下内容并将其保存为HTML。
的所有css属性似乎都可以使用,除了 content属性没有显示。谢谢。
Iv'e copied the following from the book and saved it as HTML. all the css properties seem to work except the "content" property which does not display.Thanks in advance.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title> The content property </title>
<style type='text/css' media='all'>
div {
content: "Hello, world!";
}
</style>
</head>
<body>
<div></div>
</body>
</html>
推荐答案
内容
与:before
或:after
一起使用:
div:after
{
content: "Hello, world!";
}
无论如何,我只使用了内容
用于特殊情况(例如,清除浮动元素)。我从未真正使用它来插入内容。您通常无论如何都希望将内容和表示分开,所以我认为这是一个坏主意。您正在读哪本书? :)
Regardless, I've only used content
for special cases (to clear floated elements, for example). I've never actually used this to insert content. You generally want to separate content and presentation anyway, so I think this is a bad idea. Which book are you reading? :)
这篇关于CSS内容属性未显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文