CSS多个类/ID选择器? [英] css multiple class / id selectors?

查看:393
本文介绍了CSS多个类/ID选择器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何编写一个适用于多个 ids 或多个 classes 的css块:

I'd like to know how to write a css block that applies to either multiple ids or multiple classes:

类似的东西:

.class1, .class2 {
 ...
}

#id1, #id2 {
 ...
}

我想知道两种情况下的处理方法(希望它们符合跨浏览器的要求).谢谢.

I'd like to know how to do both cases (which hopefully are cross browser compliant). Thanks.

更新:为了使其更有趣,这是否有效?

Update: To make it more interesting, is this valid too?

#id tr, #id2 tr {

}

?

推荐答案

您正在寻找这样的东西:

You are looking for something like this :

.oddBoxOut, 
.evenBoxOut {
  width: 12em;
  padding: 0.5em;
  margin: 0.5em;
  border: solid 1px black;
}

.oddBoxOut {
  float: left;
}

.evenBoxOut {
  float: right;
}

更新:

p#exampleID1 { background-color: blue; } 
p#exampleID2 { text-transform: uppercase; }

这篇关于CSS多个类/ID选择器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆