我爲通用超鏈接設計了一些CSS樣式。我想爲特定div內的超鏈接標題指定其他一些CSS。 請看下面的HTML代碼。我只想爲div類框中的h2標題指定不同的樣式。用於標題鏈接的不同的CSS
<a href="example.com" title="title">Normal Link </a>
<div class ="box">
<h2><a href="example.com" title="heading">Heading Should be red. </a></h2>
<a href="example.com" title="links">Should be normal green</a>
</div>
這裏是CSS代碼:
a:link, a:visited{
text-decoration: underline;
color: green;
}
a:hover{
text-decoration: none;
}
.box{
border: 1px dashed pink;
width:400px;
height: 100px;
margin:10px 0px;
}
.box h2{
color: red;
font-size:24px;
}
這裏是的jsfiddle演示: http://jsfiddle.net/HVX3d/1/