【问题标题】:I have defined 15 classes with name box1, box2, box3,...box15. How can I define the class without comma separation?我已经定义了 15 个名称为 box1、box2、box3、...box15 的类。如何在没有逗号分隔的情况下定义类?
【发布时间】:2016-10-07 07:38:33
【问题描述】:

我已经定义了 15 个名为 box1、box2、box3、...box15 的类。所有类的样式属性都相同。如何在没有逗号分隔的情况下定义类名?

现在,我已经定义了如下的类,

.box1, .box2, .box3, .box4, .box5, .box6, .box7, .box8, .box9, .box10, .box11,
.box12, .box13, .box14, .box15 {
     border: 2px solid black;
     height: 50px;
     width: 50px;
}

稍后我想使用这个类来应用不同的悬停样式。

【问题讨论】:

    标签: php html css


    【解决方案1】:

    试试这个

    div[class^="box"], div[class*=" box"] {
        border: 2px solid black;
         height: 50px;
         width: 50px;
    }
    

    基本上,您正在尝试在 css 中搜索通配符。您可以查看更多here

    【讨论】:

    • 谢谢,这正是我想要的答案。
    猜你喜欢
    • 1970-01-01
    • 2018-01-03
    • 1970-01-01
    • 2012-08-16
    • 2021-12-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多