简体   繁体   English

既然已经声明了类,为什么还需要使用元素?

[英]Why do we need to use element when we have already stated class?

In css, if a person has already stated a class then why does he need to use element after that like what will be the benefits of doing that.在 css 中,如果一个人已经声明了一个类,那么他为什么需要在此之后使用元素,比如这样做的好处是什么。 For example: There is a class of "content" in element So what will be the difference in css between: .content h1 {...} And .content {....}例如:元素中有一类“内容”那么css之间的区别是什么: .content h1 {...} 和 .content {....}

.content h1代表任何h1标签到所有具有 class 作为content的元素内的任何级别的子组件,而.content指的是具有 class 作为content的元素。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM