[英]CSS - how to overwrite using CSS?
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? 编辑:它将仅使用“ mytitle”标签,而不使用alt或alt2,为什么?
您需要删除类定义之间的空格:
.mytitle.alt
simple remove .mytitle 简单删除.mytitle
.alt{ color: red;}
.alt2{ color: black;}
and you will get all alt/alt2 colored, or 您将获得所有alt / alt2颜色,或
.mytitle.alt{ color: red; }
.mytitle.alt2{ color: black;}
for the both together. 为两者在一起。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.