CSS属性内容的空值有什么作用? [英] What does an empty value for the CSS property content do?
问题描述
nav ul:after {
content:"";
clear:both;
display:block;
}
$ c $是什么c>值是否表示内容属性?
What does the ""
value mean on the content property?
推荐答案
这只是一个明确的解决方案,也就是说,如果您的 ul
元素已浮动 li
,它们将被自动清除,其行为类似于 overflow:hidden;
,但不同于 overflow:hidden;
不会隐藏溢出的内容。
It's just a clearfix, which means, if your ul
elements have floated li
, than they will be self cleared, it just behaves similar to overflow: hidden;
but unlike overflow: hidden;
it wont hide the overflowing content.
演示 (无clearfix)
Demo (Without clearfix)
演示2 (带有clearfix)
Demo 2 (With clearfix)
以及为什么需要清除
以及需要清除的内容,为此,您可以参考我的答案此处
And why you need to clear
and what you need to clear, for that, you can refer my answer here
在编辑问题时, content
属性与一起使用:之前
或:after
伪之后将虚拟内容嵌入页面,因此使用 content:;
表示空白,则您没有在页面中嵌入任何字符。
As you edited your question, content
property is used with :before
or :after
pseudo to embed virtual content on the page, so using content: "";
means just blank, you are not embedding any character in your page.
这篇关于CSS属性内容的空值有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!