当前位置:网站首页>4. Relationship selector (parent-child relationship, ancestor offspring relationship, brother relationship)
4. Relationship selector (parent-child relationship, ancestor offspring relationship, brother relationship)
2022-06-13 08:41:00 【zhengqiqiqinqin】
1、 Child Selector :
HTML Code :
<div>
<p>
I am a p The text in the element
<span> This is a p In the element span</span>
</p>
<span> This is a div Inside span</span>
</div>
<div>
<span> This is the first 2 individual div Inside span</span>
</div>Corresponding CSS Code :
<style>
/*
Parent element : Elements that directly contain child elements are called parent elements
Subelement : Elements directly contained by the parent element are called child elements
Ancestral elements :
- Elements that directly or indirectly contain descendant elements are called ancestor elements
- The parent element of an element is also the ancestor element of that element ( The parent element is a special ancestor element )
Progeny element :
- Elements contained directly or indirectly by ancestral elements
Child Selector :
effect : Select the specified child element of the specified parent element
grammar : Parent element > Subelement
give an example : as follows
*/
div>span{
color:blue;
}
</style>The operation results are as follows : Only div Subelements span To blue ( all div Directly span The element turns blue , There are several such structures , They all change color ),p Under the element span Elements do not change color , because p Under the element span The element is div The offspring element of .

2、 Descendant element selector
HTML Code :
<div>
<p>
I am a p The text in the element
<span> This is a p In the element span</span>
</p>
<span> This is a div Inside span</span>
</div>
<div>
<span> This is the first 2 individual div Inside span</span>
</div>Corresponding CSS Code :
/* Descendant element selector
effect : Select the specified descendant element of the specified element
grammar : Ancestral elements Progeny element
give an example : as follows
*/
div span{
color:rgb(20, 220, 63);
}Running results :

3.1、 Brother selector 1: Select the element after Next to it first Brother element
HTML Code :
<div>
<p>
I am a p The text in the element
<span> This is a p In the element span</span>
</p>
<span> This is a div Inside span</span>
</div>
<div>
<span> This is the first 2 individual div Inside span</span>
</div>CSS Code :
/* Brother selector 1: Choose the brother next to you
grammar : The former element + The latter element ( Act on the next element )
*/
p+span{
color:chartreuse;
}Running effect :

3.2、 Brother selector 2: Select the element after All brother elements
HTML Code :
<div>
<p>
I am a p The text in the element
<span> This is a p In the element span</span>
</p>
<span> This is a div Inside span1</span>
<span> This is a div Inside span2</span>
<span> This is a div Inside span3</span>
</div>CSS Code :
/* Brother selector two
Select all the brothers below
grammar : The former element ~ The latter element ( Act on the following elements ) ( This is the wave line )
*/
p~span{
color:rgb(0, 139, 7);
}Running results :

边栏推荐
- JS - max. of array cases
- DIY UAV (anonymous controller p2+f330 rack)
- Format_ String_ Server
- JS - set countdown for Date object case
- Deploy Yum warehouse and NFS shared services
- Form exercise 2
- 淘宝商品历史价格接口/商品历史价走势接口代码对接分享
- JD commodity detail interface, JD detail page interface, baby detail page interface, commodity attribute interface, commodity information query, commodity detail interface, H5 details, JD app details,
- 天猫商品详情接口,天猫商品优惠券接口,天猫api接口,天猫价格监控接口,天猫比价接口,品牌维权接口,天猫销量api接口,接口代码可对接数据分析业务,品牌维权,比价业务,行业分析业务接口代码分享
- MySQL query exercise
猜你喜欢

Buffer Overflow Vulnerability Lab

Bidirectional retransmission step experiment

array_ Pop error: only variables should be passed by reference

JS - array de duplication in the array object case

關於RSA加密解密原理

AcWing 1977. Information relay (base ring tree, parallel search set)

Vs installation of vassistx plug-in causes Chinese input of wpf-xaml file to be garbled. Solution

Print an array clockwise

Learning record 4:einops / / cudnn benchamark=true // hook

HCIP_ Static experiment
随机推荐
SQL injection question type (manual injection +sqlmap)
Namespace in TS (1)
[virt manager] remote management the problem of the floating mouse when starting the virtual machine
The method of SolidWorks modifying text font in engineering drawing
Process and scheduled task management
JD commodity detail interface, JD detail page interface, baby detail page interface, commodity attribute interface, commodity information query, commodity detail interface, H5 details, JD app details,
Problems in the deconstruction and assignment of objects, comparison between empty strings and undefined
Taobao commodity historical price interface / commodity historical price trend interface code docking and sharing
天猫商品详情接口,天猫商品优惠券接口,天猫api接口,天猫价格监控接口,天猫比价接口,品牌维权接口,天猫销量api接口,接口代码可对接数据分析业务,品牌维权,比价业务,行业分析业务接口代码分享
从零开始-实现JpetStore网站-1-建立项目框架以及项目介绍
情绪处理技巧
anaconda下安装pytorch
Filebeat collects logs to elk
Svg text stroke effect
How to download and install stm32cubemx
Yarn package management tool
MySQL query exercise 3
Numeric types in SQL. Try to avoid using null as the default value
Journal d'acquisition du faisceau de fichiers à Elk
PHP isset() method ignores data error handling caused by null parameter value