这里有一些来 self 正在制作的网站的代码。我在设置 CSS 中的链接样式时遇到问题。我不确定为什么他们不会改变。我使用 class 的原因也是因为我将这段代码重复了 4 次(不用担心为什么 :P)顺便说一句,我也尝试将 'a' 放在 .profileLinks 的前面,但它也不起作用 :(
这是外部CSS样式表
#trends .profileLinks a:link{
color:#0000FF;
text-decoration:none;
background: transparent;
}
#trends .profileLinks a:visited {
text-decoration: none;
color: #0000FF;
background: transparent;
}
这是HTML代码
<div id="trends">
<h1> Trends... </h1>
<a href="#" title="Profile Image"><img src="logo.png" alt="Profile Image" height="59" width="68"> </a>
<a class="profileLinks" href="#" title="User's Profile Name"> Mark Fonacier </a>
<a class= "commentLinks" onClick ="javascript:ShowHide('HiddenDiv')" href="javascript:;" ><i>Comment</i></a>
<br/>
<p>
PostPostPostPostPostPostPostPostPostPostPostPostPostPostPostPostPostPostPostPostPostPostPostPostPostPost
</p>
<a onClick ="javascript:ShowHide('HiddenDiv')" href="javascript:;" ><i>Comment</i></a>
<div class="mid" id="HiddenDiv" style="DISPLAY: none" >
<form method="post" action="">
<textarea name="comments" cols="60" rows="2" placeholder="Enter your comments here..." maxlength="1000">
</textarea>
<input type="submit" value="Submit" />
</form>
</div>
<br/>
最佳答案
这个选择器,
#trends .profileLinks a:link
只对 child 有效 <a>
类为 profileLinks
的元素标签,而你的 <a>
是应用了类的元素。像这样改变它:
#trends a.profileLinks:link
其他规则也是如此。
关于html - 如何更改以下链接的样式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10380142/