CSS3中结构伪类选择器——root、not、empty、target选择器
来源:互联网 发布:淘宝卖家手续费 编辑:程序博客网 时间:2024/06/01 20:35
1.root选择器
将样式绑定到页面的根元素中。根元素是指位于文档树中最顶层结构的元素,在HTML页面中就是指包含整个页面的<html>部分。
<style type="text/css">
:root{
background:yellow;
}
body{
background:green;
}
</style>
注意:不使用root选择器来指定root元素的背景色,只指定body元素的背景色,则整个页面就全部变成了绿色。
2.not选择器
如果想对某个结构元素使用样式,但是想排除这个结构元素下面的子结构元素,让它不使用这个样式时,可以使用not选择器。
body*:not(h1){
background:yellow;
}
3.empty选择器
适用empty选择器来指定当元素中内容为空白时使用的样式。
:empty{
background:yellow;
}
4.target选择器
使用target选择器来对页面中某个target元素(该元素的id被当做页面的超链接来使用)指定样式,该样式只在用户点击了页面的超链接,并且跳转到target元素后起作用。
<style type="text/css">
:target{
background:yellow;
}
</style>
<a href="#text1">文字1</a>
<div id="text1">
<h1>文字1</h1>
<p>此处省略100个字</p>
</div>
0 0
- CSS3中结构伪类选择器——root、not、empty、target选择器
- CSS3伪类选择器之结构选择器root,not,empty,target
- 【CSS3】---结构性伪类选择器-root+not+empty+target
- CSS3常用的结构性伪类选择器①:root not empty target
- 【CSS3】结构性伪类选择器—empty
- 【CSS3】结构性伪类选择器—target
- 【CSS3】 结构性伪类选择器—root
- 【CSS3】结构性伪类选择器—not
- CSS3 选择器——伪类选择器
- CSS3 选择器——伪类选择器
- CSS3 选择器——伪类选择器
- CSS3 选择器——伪类选择器
- CSS3 选择器——伪类选择器
- CSS3 选择器——伪类选择器
- CSS3 选择器——伪类选择器
- CSS3 选择器——伪类选择器
- CSS3 选择器—伪类选择器
- CSS3选择器:属性、:root、:not、:empty、:target、first-child、last-child....
- poj 2240 Arbitrage(floyd/bellman判正圈)
- JavaScript字符串转换成数字的三种方法
- CSS3属性选择器
- CSS中伪类选择器及伪元素
- 如何将word文档转换成电子书?
- CSS3中结构伪类选择器——root、not、empty、target选择器
- CSS3中first-child、last-child、nth-child、nth-last-child
- java笔记-接口
- CSS3中nth-of-type和nth-last-of-type
- CSS3中only-child伪类选择器
- CSS3使用content属性来插入项目编号
- CSS3让文本自动换行——word-break属性
- CSS3让长单词与URL地址自动换行——word-wrap属性
- CSS3对于盒中容纳不下的内容的显示——overflow属性