【发布时间】:2016-02-15 03:14:32
【问题描述】:
是否可以将多个类添加到一个 div 元素?我尝试添加 full 和 b 类,但它不起作用。
#card {
/* default for card */
width: 300px;
height: 50px;
padding: 15px;
background-color: yellow;
box-shadow: 10px 10px 40px grey;
}
#card.g {
background-color: lightgreen;
box-shadow: 10px 10px 40px grey;
}
#card.b {
background-color: lightblue;
box-shadow: 10px 10px 40px grey;
}
#card.full{
width:100%;
height:100%;
padding:10px;
}
<h3 id="card" class="full" class="b">Hi!</h3>
如果这是一个不好的问题,我很抱歉,我是编程新手。
【问题讨论】:
-
目前它不起作用,因为浏览器只呈现第一类属性。
-
是的,只需添加由空格分隔的不同类。 class="全b"