Oli*_*ver 2 html css overriding
我有一个使用2个css的站点:一个全局,一个页面特定.
默认情况下,我想为所有内容设置字体类型和大小,并根据我在某些页面上的需要进行调整.
所以我有 :
global.css中
* {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
html {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
body {
font-family: Arial, Helvetica, sans-serif;
margin: 0px;
}
p {
text-align:justify;
margin:0px;
margin-bottom:10px;
}
a:link {
color: #993300;
text-decoration: none;
}
a:visited {
color:#993300;
text-decoration: none;
}
a:hover {
color: #FF0000;
text-decoration: underline overline;
}
Run Code Online (Sandbox Code Playgroud)
news.css
div.news{
width: 100%;
}
.news p.reminder {
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
color: #848484;
margin:0px;
margin-bottom:20px;
text-align: center;
position: relative;
top: -10px;
text-transform: uppercase;
}
.news p.reminder a:link, .news p.reminder a:visited {
color: #848484;
}
.news p.reminder a:hover {
}
Run Code Online (Sandbox Code Playgroud)
HTML文件
<HTML>
<HEAD>
<TITLE>the title</TITLE>
<LINK href="global.css" rel="stylesheet" type="text/css">
<LINK href="news.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY>
<DIV class="news">
<P class="reminder">
<A href="some_url">some text</A>
</P>
</DIV>
</BODY>
</HTML>
Run Code Online (Sandbox Code Playgroud)
我没有看到的原因,部分:
.news p.reminder {
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
Run Code Online (Sandbox Code Playgroud)
没有考虑到.
如果我从global.css中删除*定义,那就没问题.但是,如果我保留它,那部分不会覆盖它.
我该怎么做才能做到这一点?
您没有看到它的原因是,虽然段落确实采用了您想要的样式,但*选择器会匹配<A href="some_url">并立即将其更改回来.
您可以修改选择器以匹配a元素,但我将设置字体样式body而不是*