gpt4 book ai didi

css - 减少CSS代码

转载 作者:太空宇宙 更新时间:2023-11-03 19:50:00 24 4
gpt4 key购买 nike

我创建了两个具有相同属性但只有一个属性(宽度)不同的类,那么如何减少 css 代码?

.login-box button{
width: 100%;
height: 40px;
background-color: #ffd133;
color: #ffffff;
text-transform: uppercase;
font-size: 14px;
font-weight: bold;
border: 1px solid #ffd133;
border-radius: 5px;
cursor: pointer;
}


.add-category-box button{
width: 48%;
height: 40px;
background-color:#ffd133;
color: #ffffff;
text-transform: uppercase;
font-size: 14px;
font-weight: bold;
border: 1px solid #ffd133;
border-radius: 5px;
cursor: pointer;
}

最佳答案

您可以使用逗号 (,) 分隔符对选择器进行分组:

.login-box button,
.add-category-box button {
width: 100%;
height: 40px;
background-color: #ffd133;
color: #ffffff;
text-transform: uppercase;
font-size: 14px;font-weight: bold;
border: 1px solid #ffd133;
border-radius: 5px;
cursor: pointer;
}

.add-category-box button {
width: 48%;
}

关于css - 减少CSS代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34565475/

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