sách gpt4 ai đã đi

Bộ chọn [thuộc tính|=giá trị] và [thuộc tính*=giá trị] của CSS

In lại 作者:行者123 更新时间:2023-12-02 15:15:38 35 4
mua khóa gpt4 Nike

为什么我们需要CSS [attribute|=value] Selector根本当 CSS3 [attribute*=value] Selector基本上完成相同的事情,浏览器兼容性几乎相似?是否存在第一个 CSS 选择器可以执行而第二个 CSS 选择器无法执行的操作?这是第一次遇到两个非常相似的选择器,并且想知道为什么第一个选择器存在。

1 Câu trả lời

来自文档:

[attr|=value] Represents an element with an attribute name of attr. Its value can be exactly “value” or can begin with “value” immediately followed by “-” (U+002D). It can be used for language subcode matches.

[attr*=value] Represents an element with an attribute name of attr and whose value contains at least one occurrence of string "value" as substring.

视觉差异:

[attr|=值]

/* Any span in Chinese is red, matches simplified (zh-CN) or traditional (zh-TW) */
span[lang|="zh"] {color: red;}
zh

[attr*=值]

/* All links to with "example" in the url have a grey background */
a[href*="example"] {background-color: #CCCCCC;}
example

在同一代码示例中:

div[color|="red"] {
background: red;
}
div[color*="blue"] {
color: blue;
}

This shoud has only red background

This shoud has only blue color

This shoud has blue color and red background

This shoud be only blue color

引用文献

Attribute selectors

关于CSS [属性|=值] 与 [属性*=值] 选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29918932/

35 4 0
行者123
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com