/* 示例代码:使用属性选择器 */
/* 选择具有指定属性的元素 */
input[type="text"] {
border: 2px solid blue;
}
/* 选择具有指定属性和值的元素 */
a[href="https://example.com"] {
color: green;
}
/* 选择具有指定属性且值包含特定单词的元素 */
img[src*="logo"] {
border: 1px solid red;
}
/* 选择具有指定属性且值以特定值开头的元素 */
a[href^="https"] {
font-weight: bold;
}
/* 选择具有指定属性且值以特定值结尾的元素 */
a[href$=".pdf"] {
background-color: yellow;
}
input[type="text"]
:选择所有 type
属性值为 text
的 <input>
元素。a[href="https://example.com"]
:选择所有 href
属性值为 https://example.com
的 <a>
元素。img[src*="logo"]
:选择所有 src
属性值中包含 logo
的 <img>
元素。a[href^="https"]
:选择所有 href
属性值以 https
开头的 <a>
元素。a[href$=".pdf"]
:选择所有 href
属性值以 .pdf
结尾的 <a>
元素。上一篇:css 文字渐变
下一篇:css单行文本溢出省略号
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站