gpt4 book ai didi

css - 如何禁用文件中的选择器

转载 作者:行者123 更新时间:2023-11-28 18:07:01 25 4
gpt4 key购买 nike

我有一个 style.css 文件。有

.example {
float: none;
left: 4px;
position: absolute;
top: 3px;
}

现在,我尝试禁用 .example 类中的某些属性以

.example {
bottom: 20px;
}

我像下面这样尝试,但那不起作用

<style type="text/css">
.example {
bottom: 20px !important;
top: none !important;
left: none !important;
position: none !important;
}
</style>

这可能吗?我不想直接在文件中更改?

最佳答案

您试图覆盖它的属性无效。

enter image description here

没有position:nonetop:noneleft:none这样的东西..

相反,使用类似的东西:

.example {
bottom:20px;
top:auto;
left:auto;
position:static;
}

这样做将成功覆盖每个属性并将其设置回默认值。

jsFiddle here

使用 auto 实质上会将属性重置为其初始值,不需要 !important

除了仅仅覆盖属性之外,您总是可以一开始就删除它们 - 大多数时候......

关于css - 如何禁用文件中的选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19441569/

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