
这是一个全面的 css 选择器备忘单,涵盖了您可能需要的所有基本和高级选择器:
* {
margin: 0;
}
p {
color: blue;
}
.container {
width: 100%;
}
#header {
background-color: grey;
}
[type="text"] {
border: 1px solid black;
}
[type="checkbox"] {
display: inline-block;
}
[href^="https"] {
color: green;
}
[href$=".pdf"] {
color: red;
}
[class*="button"] {
font-weight: bold;
}
div p {
color: blue;
}
ul > li {
list-style-type: none;
}
h2 + p {
margin-top: 0;
}
h2 ~ p {
color: green;
}
a:hover {
text-decoration: underline;
}
input:focus {
border-color: blue;
}
li:nth-child(2) {
color: red;
}
p:nth-of-type(3) {
font-size: 1.2em;
}
p:first-child {
font-weight: bold;
}
p:not(.highlight) {
color: grey;
}
p::before {
content: "note: ";
font-weight: bold;
}
p::first-letter {
font-size: 2em;
}
p::first-line {
font-style: italic;
}
h1, h2, h3 {
color: blue;
}
div:empty {
display: none;
}
input:enabled {
background-color: white;
}
input:disabled {
background-color: lightgrey;
}
input:checked {
border-color: green;
}
tr:nth-child(even) {
background-color: lightgrey;
}
li:nth-last-child(1) {
color: red;
}
div:only-child {
border: 1px solid red;
}
:root {
--main-color: blue;
}
[required] {
border: 2px solid red;
}
[href^="http"] {
text-decoration: underline;
}
[href$=".pdf"] {
color: red;
}
[class*="icon"] {
background-color: yellow;
}
p:lang(en) {
color: blue;
}
#section:target {
background-color: yellow;
}
本备忘单涵盖了大多数 css 选择器,从基础到高级。以创造性的方式组合它们可以让您有效地定位特定元素并精确控制网页的外观。
以上就是CSS 选择器备忘单的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号