Laravel  
laravel
文档
数据库
架构
入门
php技术
    
Laravelphp
laravel / php / java / vue / mysql / linux / python / javascript / html / css / c++ / c#

css属性选择器

作者:碎花洋裙的优雅   发布日期:2025-09-14   浏览:89

/* 示例代码:使用属性选择器 */

/* 选择具有指定属性的元素 */
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单行文本溢出省略号

大家都在看

css好看的字体

css 红色

css 瀑布流布局grid

css文字超长省略号

css 渐变字体

css背景图片等比例缩放

css文字删除线

animation css3

css 自定义滚动条

css 扇形

Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3

Laravel 中文站