一个CSS的问题,高手进来哦!

来源:百度知道 编辑:UC知道 时间:2024/05/22 03:26:17
像下面这段代码,“天津市”和“海口市”这两个链接已经有样式定义了,我现在想用a link{color:#cccccc;}这样的语句重新定义,对“天津市”和“海口市”这两个连接起不到作用,原因是在其他的地方已经定义了他们的样式,我现在怎么样才能在不知道何处定义的情况下,重新自己定义他们的样式呢?

比如:#userTalk a{color:#cccccc;} (这样我试过,不对)

<div class="box" id="userTalk">
<div class="boxcont">
<ol id="talk">
<li>
<div class="article">
<div class="info">
<span class="author""><a href="iyiedu.com"><strong>天津市</strong></a></span>
</div>
</div>
</li>

<li>
<div class="article">
<div class="info">
<span class="author"><a href="iyiedu.com"><strong>海口市</strong></a></span>

</div>

</div>

</

因为你用错格式了,你定义的范围太大,肯定不能实现
你这样定义

.author a{color:#cccccc;}
或者
span a{color:#cccccc;}

相信我,没错的!!

可以用内嵌样式覆盖已有样式,比如:
<p style = "font-size:30pt">
<a href="iyiedu.com" style = "color:#cccccc"><strong>海口市</strong></a></span>

<link rel=stylesheet href="a.css" type="text/css">
<link rel=stylesheet href="b.css" type="text/css">
把你想要使用的css放在后面。你把自己想的属性方在b.css中,放其他css的后面。
还有一个办法是在你要声明的属性上加!important属性。