css复习——结构性伪类
来源:互联网 发布:淘宝客服子取名字大全 编辑:程序博客网 时间:2024/05/20 19:46
0803
结构性伪类
<style> p:nth-child(3){ background-color: #000000; }</style>
p:nth-child(n) 表示p元素的父级中的第n个子元素 并且这个子元素必须是p,否则没有反应。
<style> p:nth-last-child(2){ background-color: #000000; }</style>
p:nth-last-child(n) 表示p元素的父级中的第n个子元素 并且这个子元素必须是p 顺序从后往前数。
p:nth-last-child(1) 会选中p父元素中的最后一个子节点,并且这个子节点必须是p,否则没有反应。
<style> .list:nth-of-type(1){ background-color: #000000; }</style>
p:nth-of-type(n) 表示p元素的父级中的第n个p元素。
<style> p:nth-last-of-type(1){ background-color: #000000; }</style>
p:nth-of-type(n) 表示p元素的父级中的第n个p元素 顺序从后往前数。
<style> p:first-child{ background-color: #0e3757; }</style>
p:first-child 表示p元素的父级中的第一个子元素,并且这个元素必须是p
<style> p:last-child{ background-color: #0e3757; }</style>
p:last-child 表示p元素的父级中的最后一个子元素,并且这个元素必须是p。
<style> p:first-of-type{ background-color: #0e3757; }</style>
p:first-of-type 表示p元素的父级中的第一个p元素
<style> p:last-of-type{ background-color: #0e3757; }</style>
p:last-of-type 表示p元素的父级中的最后一个p元素
<style> h1:only-child{ background-color: #F06000; }</style>
h1:only-child 表示h1元素的父级中的唯一一个元素,并且这个元素必须是h1(!不能有其他元素)
<style> p:only-of-type{ background-color: #0e3757; }</style>
p:only-of-type 表示p元素的父级中的唯一一个p元素(父级中可以存在其他元素)
阅读全文
0 0
- css复习——结构性伪类
- 结构性伪类选择器—not
- 【CSS3】 结构性伪类选择器—root
- 【CSS3】结构性伪类选择器—not
- 【CSS3】结构性伪类选择器—empty
- 【CSS3】结构性伪类选择器—target
- 结构性伪类选择器—root
- 结构性伪类选择器—not
- 结构性伪类选择器—empty
- 结构性伪类选择器—target
- 结构性伪类选择器—first-child
- 结构性伪类选择器—last-child
- 【CSS3】结构性伪类选择器—first-child
- 【CSS3】结构性伪类选择器—last-child
- 【CSS3】结构性伪类选择器—nth-child(n)
- 【CSS3】结构性伪类选择器—nth-last-child(n)
- 结构性伪类选择器—nth-child(n)
- 结构性伪类选择器—nth-last-child(n)
- 流水账笔记:PE文件格式(OptionalHeader 下)
- 认识集线器、交换机(全称内网交换机)、路由器
- 闭包补充
- 欢迎使用CSDN-markdown编辑器
- 第一次使用Android Studio时你应该知道的一切配置
- css复习——结构性伪类
- 求解斐波拉契数列
- Zookeeper框架Curator之事件监听-yellowcong
- 深度学习(一):神经网络和反向传播
- c++中栈和队列的头文件
- HDU 5195 DZY Loves Topological Sorting 拓扑序(贪心)
- break; goto, return; 的用法
- Struts2 知识点梳理
- Java垃圾回收算法