I am trying to style these elements, and the element with two classes can't be style different than the one with one class. I've tried to select it with .red.balls
also, but it doesn't work.
.ballsAll { display: block; margin-left: 14%; } .red { background-color: red; } .balls { background-color: white; }
<div class='ballsAll'> <p> <span class='balls'>22</span> <span class='balls red'>11</span> </p> </div>
Declare .balls before .red, Like this:
.ballsAll {
display: block;
margin-left: 14%;
}
.balls {
background-color: white;
}
.red {
background-color: red;
}
<div class='ballsAll'>
<p>
<span class='balls'>22</span>
<span class='balls red'>11</span>
</p>
</div>
Use this code:
.ballsAll { display: block; margin-left: 14%; } .red.balls { background-color: red; } .balls { background-color: white; }
<div class='ballsAll'> <p> <span class='balls'>22</span> <span class='balls red'>11</span> </p> </div>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.