How to write multiple css selectors in one line?

ぃ、小莉子 提交于 2021-02-05 06:44:26

问题


My problem is that i want to write this in single selection :

.btn-primary > i.glyphicon {
    color: #ffffff;
}
.btn-primary > span.glyphicon {
    color: #ffffff;
}

But this :

.btn-primary > i.glyphicon, span.glyphicon {
    color: #ffffff;
}

doesnt work. Because all the span.glyphicon tags are geting white color. How do solve this?


回答1:


Comma separate them:

.btn-primary > i.glyphicon,
.btn-primary > span.glyphicon {
    color: #ffffff;
}

More info can be found at w3.org about grouping.

If you want to 'shortcut' them, you'll need a CSS pre-processor, like SCSS or SASS.



来源:https://stackoverflow.com/questions/29685752/how-to-write-multiple-css-selectors-in-one-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!