我上过这样的课
.lifetime .containerrow
{
text-align: center;
height: 20px;
}我需要将一些元素中的文本设置为粗体,所以我这样做了:
.lifetime .containerrow .info
{
font-weight:bold;
}这个不起作用,但这个起作用了:
.lifetime.containerrow.info
{
font-weight:bold;
}为什么?不是一回事吗?
谢谢
不太了解css
发布于 2012-10-18 16:26:24
这是正确的行为。.class1.class2.class3匹配具有所有三个类的元素。.class1 .class2 .class3与.class3的元素匹配,该元素位于.class2的元素内,.class1的元素内。
如果要将相同的样式应用于三个单独的类,则需要用逗号分隔它们(例如.class1, .class2, .class3 { font-weight: bold; })
发布于 2012-10-18 16:26:56
.lifetime .containerrow .info
{
font-weight:bold;
}表示具有嵌套在.containerrow中的.info类的元素,该元素嵌套在.lifetime中
.lifetime.containerrow.info
{
font-weight:bold;
}表示具有.lifetime、.containerrow和.info类的元素
发布于 2012-10-18 16:27:38
我假设您想要对多个类应用粗体粗体:
.lifetime,
.containerrow,
.info
{
font-weight:bold;
}https://stackoverflow.com/questions/12950180
复制相似问题