html元素可以具有多个属性,html – 是否有一个具有相同属性值的2个或更多元素的选择器?...

是否有更优雅的方式来写这个?

.standard {

padding-top: 50px;

padding-bottom: 50px;

}

.standard.color-0 + .standard.color-0,

.standard.color-1 + .standard.color-1,

.standard.color-2 + .standard.color-2,

.standard.color-3 + .standard.color-3,

.standard.color-4 + .standard.color-4,

.standard.color-5 + .standard.color-5,

.standard.color-6 + .standard.color-6,

.standard.color-7 + .standard.color-7,

.standard.color-8 + .standard.color-8 {

padding-top: 0;

}

是否有一些选择器可以检查在2个或更多元素上找到的类的匹配,而实际上并不知道确切类的名称?比如:

.standard.color-* + .standard.color-* {

padding-top: 0;

}

我目前(上面发布的)的工作方式与我在网站上显示的方式一样,但我只是好奇我是否注定要不断添加.standard.color-#.standard. color-#为我需要的每种新颜色(在这种情况下,对于全宽< section>标记,它是背景颜色).

例子:

// top and bottom padding

// top and bottom padding

-----------------------------------------------------------------------

// top and bottom padding

// padding-top: 0; (if both "color-#" is the exact same this loses its top padding)

编辑:简化的帖子和代码. 将始终有一个.standard类和一个.color-类,其中.color-0是background-color:transparent;.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值