CSS 最重要的一环就是选取器,新手一定要了解熟悉 CSS 选取器
才能事办功倍,开发速度也会提升许多
今天就来写下我常用的选取器笔记吧:)
:first-child
选取第一个子物件
p:first-child {
color: red;
}
:first-of-type
选取第一个类型
p:first-of-type {
color: red;
}
:last-child
选取最後一个子物件
p:last-child {
color: red;
}
:last-of-type
选取最後一个类型
p:last-of-type {
color: red;
}
:nth-child() 第 n 个子物件
p:nth-child(1) {
color: red;
}
``
``:nth-last-child()``` 从结尾开始选取第 n 个子物件
p:nth-last-child(1) {
color: red;
}
```:nth-of-type()``` 选取第 n 的同类子物件
.wrap :nth-of-type(even) {
background-color: red;
}
``
:nth-last-of-type()
从结尾开始选第 n 的同类子物件
.wrap :nth-last-of-type(1) {
background-color: red;
}
<<: Day 13 - 物品借用纪录系统 (3) 程序码解说
昨天讲完的CSS的文字和区块属性後,今天要接续介绍版面布局的属性,以及一个非常好用的布局容器 - F...
什麽是物件导向程序设计? 物件导向程序设计 (Object-oriented programming...
今天来到阵列啦~~~((尖叫声 想当初第一次写程序时,遇到阵列我觉得好难r...... 阵列(arr...
大部分会碰到的是 Binary Tree 和 Binary Search Tree。 常见错误:nu...
为了要处理跟操作有关的事件 再开一只程序叫ActionBattle_Action.js 并一样引入该...