我试图在每个链接中获取class =“ H”以便在选择该链接时更改颜色。我尝试使用a:active{ color:#17CCB2; }
,然后
.H a:active { color:#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>
仅供参考,我真的很陌生,所以让我知道我是否过于复杂:)
答案 0 :(得分:1)
我使用并修改了您的代码。如果您只是想在.H
类中定位代码,请使用摘要(.H:active { color:#17CCB2; }
中显示的CSS。正如其他人所说,这确实可以正常工作,我将其放入一个摘要,以便您可以运行它并自己查看。
.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>
答案 1 :(得分:0)
尝试直接使用.H:active
。这将通过定位H类来选择您要定位的确切元素