开发者

CSS - how to overwrite using CSS?

开发者 https://www.devze.com 2023-03-03 08:54 出处:网络
I only want to change the colour for the title text, I dont know why the following code does not work?

I only want to change the colour for the title text, I dont know why the following code does not work?

<div 开发者_如何转开发class="mytitle">
this is the title in white
</div>

<div class="mytitle alt">
this is the title in red
</div>
<div class="mytitle alt2">
this is the title in black
</div>




.mytitle{
    font-family: Verdana, Geneva, sans-serif;
    font-size: 37px !important;
    line-height: 40px !important;
    display:block;
    font-weight: bold;
    margin: 0 0 12px;
    padding: 0 15px 5px 0 !important;
    color: white;
    width:500px;
}
.mytitle .alt{
    color: red;
}
.mytitle .alt2{
    color: black;
}

EDIT: it would only use "mytitle" tag, it would not use alt or alt2, why?


You need to remove the spaces between the class definitions:

.mytitle.alt


simple remove .mytitle

.alt{  color: red;}       
.alt2{ color: black;}   

and you will get all alt/alt2 colored, or

.mytitle.alt{ color: red; }       
.mytitle.alt2{ color: black;}  

for the both together.

0

精彩评论

暂无评论...
验证码 换一张
取 消