gpt4 book ai didi

类中所有类的CSS3 "with"选择器?它存在吗?

转载 作者:太空宇宙 更新时间:2023-11-04 14:15:50 25 4
gpt4 key购买 nike

在 ActionScript 中,我习惯了 with() 选择器,它帮助我快速将属性分配给一个对象。

对于 CSS3,我正在搜索类似的东西,所以不是:

.custom1 .redclass { background:#F00; }
.custom1 .fontbig { font-size:20px; }
.custom1 .hidden { display:none; }

我只会指定类似的内容:

with(.custom1) {
.redclass { background:#F00; }
.fontbig { font-size:20px; }
.hidden { display:none; }
}

这会大大提高我的速度并简化事情,特别是对于仅使用一个 CSS 文件定位特定于站点的 CSS。例如。每个主体都有自己的类,我可以为每个不同的页面/主体分配样式。

最佳答案

CSS3 没有您想要的。

您可以在 LESS 等 CSS 预处理器中找到您所要求的功能类型选项。具有嵌套能力。

在 LESS 中,你可以这样写:

.custom1 {
.redclass { background:#F00; }
.fontbig { font-size:20px; }
.hidden { display:none; }
}

这将处理这个:

.custom1 .redclass { background:#F00; }
.custom1 .fontbig { font-size:20px; }
.custom1 .hidden { display:none; }

关于类中所有类的CSS3 "with"选择器?它存在吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20369128/

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