如何更改 div CSS 特定类中的链接颜色
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10845517/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to change the link color in a specific class for a div CSS
提问by Anil Jain
In my Page the following CSS is set:
在我的页面中,设置了以下 CSS:
a:link {
color: #0094DE;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #0094DE;
}
a:hover {
text-decoration: underline;
color: #DD127B;
}
I want to Change the Link color inside a div which has a class assigned to it. I tried the following :
我想更改分配了类的 div 内的链接颜色。我尝试了以下方法:
register:link{color:#FFFFFF;
}
Where register is the name of the div in which i want to change the link color. How can i do that? Also how to change the color for hover link over the same div?
其中 register 是我要更改链接颜色的 div 的名称。我怎样才能做到这一点?另外如何更改同一div上悬停链接的颜色?
回答by Shehzad Bilal
.register a:link{
color:#FFFFFF;
}
回答by Aditya P Bhatt
It can be something like this:
它可以是这样的:
a.register:link { color:#FFF; text-decoration:none; font-weight:normal; }
a.register:visited { color: #FFF; text-decoration:none; font-weight:normal; }
a.register:hover { color: #FFF; text-decoration:underline; font-weight:normal; }
a.register:active { color: #FFF; text-decoration:none; font-weight:normal; }
回答by Eddie Madrigal
how about something like this ...
这样的事情怎么样...
a.register:link{
color:#FFFFFF;
}
回答by Prashobh
#register a:link
{
color:#fffff;
}
回答by sayyed tabrez
If you want to add CSS on a:hover
to not all the tag, but the some of the tag, best way to do that is by using class. Give the class to all the tags which you want to give style - see the example below.
如果您不想将 CSS 添加a:hover
到所有标签,而是一些标签,最好的方法是使用 class。将类分配给您想要赋予样式的所有标签 - 请参见下面的示例。
<style>
a.change_hover_color:hover {
color: white !important;
}
</style>
<a class="change_hover_color">FACEBOOK</a>
<a class="change_hover_color">GOOGLE</a>
回答by Eagle's Eye
I think you want to put a
, in front of a:link
(a
, a:link
) in your CSS file. The only way I could get rid of that awful default blue link color. I'm not sure if this was necessary for earlier version of the browsers we have, because it's supposed to work without a
我想你想放a
,前面a:link
(a
,a:link
)在你的CSS文件。我可以摆脱那种可怕的默认蓝色链接颜色的唯一方法。我不确定这对于我们拥有的早期版本的浏览器是否有必要,因为它应该可以在没有a
回答by user4003101
smaller-size version:
小尺寸版本:
#register a:link {color: #fff}