Html 如何为 Div 定义链接颜色?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12021045/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 02:19:45  来源:igfitidea点击:

How Can I Define Link Colours for a Div?

csshtmlcolorshyperlink

提问by Mo GaGarnsey

I'm trying to change the properties for the links in only one specific dev layer. Ideally I'd be able to have a code which kept every single link in the document the same colour despite it's status, but I don't think that's possible.

我正在尝试仅更改一个特定开发层中链接的属性。理想情况下,我可以有一个代码,尽管它的状态,但它使文档中的每个链接都保持相同的颜色,但我认为这是不可能的。

This is the coding that I have at the moment, but it's not working:

这是我目前的编码,但它不起作用:

<head>
<style type="text/css">

body {
background-color:#B7B7B7;
background-image:url('http://pophatesfags.site90.net/pophatesfags.png');
background-repeat:no-repeat;
background-position:center top;
}

.text {
font-style: italic;
border-bottom:1px dashed black;
}

div.home {
a:link { color: #70DB93; }
a:visited { color: #70DB93; }
a:hover { color: #70DB93; }
a:active { color: #70DB93; }
}

</style>
</head>

<font color="70DB93"
<div id="home" class="div" style="position:absolute; width:715; height:42; left:27%; top:178px">
<span class="text">
<a href="http://www.pophatesfags.site90.net/home.html">home</font></a></div></style>

Any help would be greatly appreciated!

任何帮助将不胜感激!

回答by some_other_guy

I assume you want to change the color of the link in 'home' div. The CSS code will be -

我假设您想更改“主页”div 中链接的颜色。CSS 代码将是 -

#home a:link { color: #70DB93; }
#home a:visited { color: #70DB93; }
#home a:hover { color: #70DB93; }
#home a:active { color: #70DB93; }

Try it and let us know!

试试吧,让我们知道!

回答by yckart

<head>
<style type="text/css">

body {
background-color:#B7B7B7;
background-image:url('http://pophatesfags.site90.net/pophatesfags.png');
background-repeat:no-repeat;
background-position:center top;
}

.text {
font-style: italic;
border-bottom:1px dashed black;
}

div#home a:link { color: #70DB93; }
div#home a:visited { color: #70DB93; }
div#home a:hover { color: #70DB93; }
div#home a:active { color: #70DB93; }

</style>
</head>

<div id="home" class="div" style="position:absolute; width:715; height:42; left:27%; top:178px">
<span class="text">
<a href="http://www.pophatesfags.site90.net/home.html">home</a></div>

?

?

http://jsbin.com/ujivoy/1/edit

http://jsbin.com/ujivoy/1/edit