gpt4 book ai didi

html - CSS 未设置未按预期工作。如何解决?

转载 作者:太空狗 更新时间:2023-10-29 15:09:45 26 4
gpt4 key购买 nike

I all: unset 取消所有继承属性但允许用户代理样式表。我该怎么做?正如您在代码中看到的那样,它禁用了所有样式,甚至是用户代理样式表。如何防止禁用用户代理样式表?

h1, h2 {
color: red;
font-size: 24px;
font-weight: bold;
}
.editor_data * {
all: unset;
}
<div class="main_block">
<h2>Should be red</h2>
<div class="editor_data">
<h1><u><em><strong>Should be underlined, bold, italics, but not red</strong></em></u></h1>
</div>
</div>

最佳答案

尝试使用关键字 revert 而不是 initialunset

The revert keyword is useful for isolating embedded widgets or components from the styles of the page that contains them, particularly when used with the all property.

In user stylesheets, revert rolls back the cascade and resets the property to the default value established by the user-agent stylesheet.

MDN

h2 {
color: red;
font-size: 24px;
font-weight: bold;
}

.editor_data * {
all: revert;
}
<div class="main_block">
<h2>Hello world!</h2>
<div class="editor_data">

<h1><u><em><strong>Hello world!</strong></em></u></h1>
</div>
</div>

关于html - CSS 未设置未按预期工作。如何解决?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55651739/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com