Time: 2024-07-21 Sunday 14:49:01
Author: Jackasher
CSS选择器
通用选择器
1 2 3 4
| ul li { color: red }
|
子代选择器
1 2 3 4
| ul > li { color: red; }
|
交集,并集选择器
1 2 3 4 5 6
| ul.li { columns: auto; } ul,li { }
|
兄弟选择器
1 2 3 4 5 6 7 8 9
| div + p { columns: auto; }
div ~ p { columns: auto; }
|
属性选择器
1 2 3 4
| [title="jack"] { column-rule: aliceblue; }
|
伪类选择器-动态
这是一种元素状态的特殊描述
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| a:link { color: rebeccapurple; }
a:visited { columns: auto; }
a:hover { columns: auto; }
a:active { columns: auto; }
input:focus { columns: auto; }
|
伪类选择器-结构
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| p:first-child { counter-reset: a; }
p:first-child { counter-reset: a; }
p:nth-child(3){ align-self: start; }
p:first-of-type { color: #000; background-color: red; }
p:nth-of-type(3) { columns: auto; }
p:nth-last-child(3) { counter-reset: a; }
p:only-child { clear: both; }
p:only-of-type { clear: both; }
p:empty { clear: both; }
|
child通常是直接的第一个,不在乎类型
否定伪类
1 2 3 4
| p:not(.fail) { clear: both; }
|
UI伪类
1 2 3 4
| input:checked { clear: both; }
|
目标伪类
1 2 3 4
| div:target { clear: both; }
|
语言选择器
1 2 3 4
| div:lang(en) { columns: auto; }
|
伪元素选择器
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| div::first-letter { clear: both; }
div::selection
div::placeholder
p::before { content: "$"; }
p::after { content: ".00"; }
|