html - 如果 :active isn't working?,如何更改链接的事件颜色

标签 html css

我试图让每个链接内的 class="H"在选择该链接时改变颜色。我尝试使用 a:active{ color:#17CCB2; } 然后 .H a:active { 颜色:#17CCB2; } 在 CSS 中,当我点击链接时似乎都没有改变颜色。这是我的 HTML 片段:

<div class="solution">
    <ul>
        <li><a id="FirstLink" href="javascript:" onclick="changeImg('images/auto-simp.gif');"><p class="solution-body"><span class="H">Auto Simplify</span><br>Automatically applies the Simplify Graphics for users that don't have the design tools, skills, or time to apply the SUI technique to their content.</p></a></li>
        <li><a id="AC" href="javascript:" onclick="changeImg('images/auto-colors@2x.png')"><p class="solution-body"><span class="H">Auto Color Palette</span><br>Technical communicators and trainers often deal with content that regularly updates or needs to be translated for multiple languages.</p></a></li>
        <li><a id="SG" href="javascript:" onclick="changeImg('images/simplifylaptop@2x.png')"><p class="solution-body"><span class="H">Simplify Graphics</span><br>Technical communicators and trainers often deal with content that regularly updates or needs to be translated for multiple languages.</p></a></li>
    </ul>
</div>

仅供引用,我对此很陌生,所以如果我让事情过于复杂,请告诉我:)

最佳答案

我使用了您的代码并稍作修改。如果你只是想在你的 .H 类中定位代码,那么使用代码段中显示的 CSS (.H:active { color:#17CCB2; } ) 正如其他人所说,这确实可以正常工作,我将其放入一个片段中,以便您可以运行它并亲自查看。

.H:active { color:#17CCB2; }
<div class="solution">
                        <ul>
                            <li><a id="FirstLink" href="javascript:" onclick="changeImg('images/auto-simp.gif');"><p class="solution-body"><span class="H">Auto Simplify</span><br>Automatically applies the Simplify Graphics for users that don't have the design tools, skills, or time to apply the SUI technique to their content.</p></a></li>
                            <li><a id="AC" href="javascript:" onclick="changeImg('images/auto-colors@2x.png')"><p class="solution-body"><span class="H">Auto Color Palette</span><br>Technical communicators and trainers often deal with content that regularly updates or needs to be translated for multiple languages.</p></a></li>
                            <li><a id="SG" href="javascript:" onclick="changeImg('images/simplifylaptop@2x.png')"><p class="solution-body"><span class="H">Simplify Graphics</span><br>Technical communicators and trainers often deal with content that regularly updates or needs to be translated for multiple languages.</p></a></li>
                        </ul>
                    </div>

关于html - 如果 :active isn't working?,如何更改链接的事件颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54242699/

相关文章:

javascript - 如何调整空格键和输入仅适用于第三个按钮而不适用于任何其他按钮?

javascript - 测试元素的样式属性和JavaScript中的css值有区别吗?

html - 2x2 图像,每个图像上的文字叠加不同

javascript - Firefox 扩展中的不透明度和 jQuery 淡入/淡出

javascript - jQuery 没有检测到 Iframe

html - 一些自定义字体不适用于 `ie10`

css - 为什么 Firefox 完全忽略我的一些 CSS?

html - 左侧下拉菜单

javascript - 我有 2 个 UI 选项卡。我需要通过单击该选项卡外的按钮来激活一个特定选项卡

jquery - 需要窗口大小调整帮助。更改 div 位置(而不是动画)