cuốn sách gpt4 ai đã làm

CSS 规范 : what has more "weight"

In lại Tác giả: Walker 123 更新时间:2023-11-28 11:08:20 28 4
mua khóa gpt4 Nike

在 css 规范中,什么会影响更多的 nội tuyến 样式或外部 !important


外部“style.css”:

#di{color: green!important;}

div 文本颜色是红色还是绿色?

如果我使用 class 或 id,它是否适用于此?

我遇到这种情况让我想到了之前的事情:


-> 我正在尝试从 CSS 更改图像,这可能吗?当我尝试使用

background-image: url(...)!important;

从外部样式表来看,它不会影响“div”。有解决办法吗?

câu trả lời hay nhất

!quan trọng 声明优先于规则特异性,但最好避免,因为它不能在没有另一个 !quan trọng 规则使用的情况下被覆盖。

CSS attempts to create a balance of power between author and user style sheets. By default, rules in an author's style sheet override those in a user's style sheet (see cascade rule 3).

However, for balance, an "!important" declaration (the delimiter token "!" and keyword "important" follow the declaration) takes precedence over a normal declaration. Both author and user style sheets may contain "!important" declarations, and user "!important" rules override author "!important" rules. This CSS feature improves accessibility of documents by giving users with special requirements (large fonts, color combinations, etc.) control over presentation.

#di{color: green!important;}
test

引用:!important rules

关于CSS 规范 : what has more "weight",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28530240/

28 4 0
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress