How to use CSS parent-child

php中世界最好的语言
Release: 2017-12-01 14:51:58
Original
4633 people have browsed it

When we are working on a front-end project, we must clarify the parent relationship between element modules, so that we can maintain and find and use elements more conveniently. Let me give you a good introduction today.

Simply speaking, CSS parent CSS child is relative. For example, a DIV "A" is wrapped by another DIV "B", so we can think that B is the parent of A. The same reason applies.

Parent-child or sometimes the DIV nested relationship is compared to the father-son relationship. This is for ease of understanding. The image of the DIV nested relationship is compared to the parent-child relationship.

, example:

DIV CSS parent-child description example:

CSS code

.yangshi{...} .yangshi .yangshi_a{ ...} .yangshi .yangshi_b{ ...}
Copy after login

Div code

内容a
内容b
Copy after login

above Here in the div+css code, we can think that the parent (upper level) of yangshi_a is yangshi.

So we can use CSS pointersAttributesIn div css, the final CSS style can have the same namedAttribute selector, But given different values.

In this way, we can know that the parent of yangshi_a is yangshi by looking at .yangshi .yangshi_a


I believe you have mastered the method after reading these cases. For more exciting content, please pay attention to php Chinese websiteOtherrelated articles!

Related reading:

How to use the transform gradient attribute in Css3

Steps to implement the effect of creating a dynamic switch in Css3

Steps to optimize HTML5 forms with CSS3

The above is the detailed content of How to use CSS parent-child. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!