html - 如何更改以下链接的样式?

标签 html css

这里有一些来 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/

相关文章:

html - 如何在切换 "text"输入时隐藏标签和 "radio"输入

css - 缩放时页面上的图像和元素未正确调整

javascript - 运行 webGL 的最低系统要求?

javascript - 具有多个元素的 addEventListener

javascript - "white-space: pre;"CSS 样式在 &lt;textarea&gt; HTML 元素中似乎不符合 W3C 规范 - 它总是换行,而不仅仅是换行

html - Internet Explorer CSS 渐变处理

html - 在一个元素中使用多个供应商标签是一种不好的做法吗?

html - CSS 背景图像不会出现在 Safari 中

css - 没有滚动条时将页脚放在底部?

html - 如何消除页面顶部的空白?