如何获得没有不同颜色的链接。 [英] How do I get links that do NOT have a different color.

查看:58
本文介绍了如何获得没有不同颜色的链接。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,IE和Netscape的默认链接样式为color:blue;

和text-decoration:underline。那很好,但是对于我来说我需要关闭默认样式。


我知道如何更改它以便它是另一种颜色,或强迫它没有下划线,或使其粗体,或斜体,或其他什么。

问题是,如何让它完全关闭音节。怎么做

我得到它不改变文本的颜色或文本装饰?


例如:考虑以下HTML示例:

< html>

< style type =" text / css">

#sheep {color:black; }

#fox {color:brown; }

#boy {color:blue; }

< / style>

< body>

< span id =" sheep"> Baa Baa< a href =" #black"> Black< / aSheep< /

span>< br />

< span id =" fox">快速< a href ="#brown">褐色< / afox在懒狗身上跳了
。< / span>< br />

< span id =" boy">小男孩< a href ="#blue"> blue< / acome blow

你的号角。< / span>< br />

< / body>

< / html>


如果您在浏览器中呈现此链接黑色,棕色和蓝色

全部为蓝色,带有下划线。我不希望链接改变

颜色。我希望颜色与句子的颜色相同

in。即对于这个例子,第一行中的链接应该是黑色的,

第二行应该是是棕色,第三个应该是蓝色,就像

周围文本的其余部分一样。


将此添加到样式部分不会工作(没想到,

但是值得一试):


a:link {color:none; }

a:visited {color:none; }

a:hover {color:none; }

a:active {color:none; }


将此添加到样式部分也不起作用:


a:link {color:inherit; }

a:visit {color:inherit; }

a:hover {color:inherit; }

a:active {color:inherit; }


我对文本修饰有同样的基本问题。我可以强制

文本修饰是一种特定的方式(即文本修饰:

下划线或文本修饰:无)但如果我想要文本

装饰是什么样的父元素文字装饰

是什么?


有什么想法吗?

-alan

解决方案

Alan写道:


好​​的,IE浏览器和Netscape的默认链接样式为color:blue;

和text-decoration:underline。这很好,但是对于我所做的事情我需要关闭默认样式。



有趣的是你会需要那。访问者应该如何找到链接?


>

我知道如何更改它所以它是另一种颜色,或强迫它没有下划线,或使它变得粗体,或斜体,或其他什么。

问题是,如何让它完全关闭音节。怎么做

我得到它不改变文本的颜色或文字装饰?



将周围文本设置为蓝色并带下划线。那么链接就不会发生变化

(直到它被访问/访问过,就是这样。)


> <例如:考虑以下HTML示例:

< html>

< style type =" text / css">

#sheep {color:black; }

#fox {color:brown; }

#boy {color:blue; }

< / style>

< body>

< span id =" sheep"> Baa Baa< a href =" #black"> Black< / aSheep< /

span>< br />

< span id =" fox">快速< a href ="#brown">褐色< / afox在懒狗身上跳了
。< / span>< br />

< span id =" boy">小男孩< a href ="#blue"> blue< / acome blow

你的号角。< / span>< br />

< / body>

< / html>



尝试修改你的CSS:


#sheep,#shep a {color:black; }

#fox,#fox a {color:brown; }

#boy,#baby a {color:blue; }


用户样式表,如果使用的话,会阻碍你的计划,但那就是它应该是b / b。


此外,您的< span> s看起来确实应该是< p> s或< div> s。

即使您将它们保持为跨度,也可以设置它们显示:块和

指定适当的边距。在任何情况下,你都可以摆脱< br> s。


HTH

-

John


Alan写道:


我知道如何改变它以使它成为另一种颜色,或强迫它

没有下划线,或者粗体,斜体或其他什么。

问题是,如何让它完全关闭音节。怎么做

我得到它不改变文本的颜色或文字装饰?



a {color:inherit;文本装饰:继承; }


-

David

Stardate 7411.5


Alan < ar ***** @ gmail.comwrites:


好​​的,IE和Netscape的默认链接样式为color:blue;

和text-decoration:underline。这很好,但是对于我所做的事情我需要关闭默认样式。



你不能解释你在做什么,所以不要提出一个

功能失调的解决方案,你可以说是


a ??我想关闭链接的默认样式.a ??


我知道如何更改它以便它是另一种颜色,或强迫它没有下划线,或使其粗体,或斜体,或其他什么。

问题是,如何让它完全关闭音节。怎么做

我得到它不改变文本的颜色或文字装饰?



删除HREF属性非常有用。删除

对应的标签效果更好。


将此添加到样式部分不起作用(没想到它)会,

,但值得一试):


a:link {color:none; }

a:visited {color:none; }

a:hover {color:none; }

a:active {color:none; }



这取决于每次拍摄的成本。人们可以指出CSS规范,但是

我宁愿指向最后一章??当然你在开玩笑,

费曼先生! a ??


将此添加到样式部分也不起作用:


a:link {color :继承; }

a:visit {color:inherit; }

a:hover {color:inherit; }

a:active {color:inherit; }



你试过吗?| ?


您正在寻找继承(不需要伪类),但是您使用错误的软件看待



如果你想在安全方面犯错,


身体,

表,

a

{

颜色:/ *插入RGB值或关键字* /;

text-decoration:none;

}


应该用一个规则集来诀窍。


大多数人都倾向于忘记添加


光标:文字





outline:none;


到那个。


为了使它成为防弹,你应该添加类似


< script type =" text / javascript">

window.onload = function(){

var a = document.getElementsByTagName(''A''),l = a.length;

while (l--){

a [l] .onclick = function(){

返回false;

}

}

}

< / script>


(有些游客只是放弃了,无论你怎么努力

劝阻他们)

- -

|||十六进制EBB

oo十进制3771

--oOo - () - oOo--八进制7273

205再见二进制111010111011


Okay, IE and Netscape have a default link style with "color: blue;"
and "text-decoration: underline". That''s fine, but for what I am
doing I need to turn OFF the default styling.

I know how to change it so that it is another color, or force it to
NOT have underlining, or make it bold, or italics, or whatever. The
problem is, how do I get it to turn the syling OFF completely. How do
I get it NOT to change the color or text-decoration of the text?

For example: consider the following HTML example:
<html>
<style type="text/css">
#sheep { color: black; }
#fox { color: brown; }
#boy { color: blue; }
</style>
<body>
<span id="sheep">Baa Baa <a href="#black">Black</aSheep</
span><br/>
<span id="fox">The quick <a href="#brown">brown</afox jumped
over the lazy dog.</span><br/>
<span id="boy">Little boy <a href="#blue">blue</acome blow
your horn.</span><br/>
</body>
</html>

If you render this in a browser the links "Black", "brown", and "blue"
are all blue with an underline. I don''t want the links to change
color. I want the color to be the same as that of the sentence it is
in. i.e. For this example the link in the first line should be black,
the second should be brown, and the third it should be blue, just like
the rest of the surrounding text.

Adding this to the style section doesn''t work (didn''t figure it would,
but it was worth a shot):

a:link { color:none; }
a:visited { color:none; }
a:hover { color:none; }
a:active { color:none; }

And adding this to the style section doesn''t work either:

a:link { color:inherit; }
a:visited { color:inherit; }
a:hover { color:inherit; }
a:active { color:inherit; }

I have the same basic question about the text-decoration. I can force
the text-decoration to be a specific way (i.e. text-decoration:
underline or text-decoration: none) but what if I want the text
decoration to be whatever the the parent elements text-decoration
is?

Any ideas?
-alan

解决方案

Alan wrote:

Okay, IE and Netscape have a default link style with "color: blue;"
and "text-decoration: underline". That''s fine, but for what I am
doing I need to turn OFF the default styling.

Interesting that you would "need" that. How is a visitor supposed to
find the link?

>
I know how to change it so that it is another color, or force it to
NOT have underlining, or make it bold, or italics, or whatever. The
problem is, how do I get it to turn the syling OFF completely. How do
I get it NOT to change the color or text-decoration of the text?

Set the surrounding text to be blue and underlined. Then no change will
occur for the link (until it''s been /visited/, that is.)

>
For example: consider the following HTML example:
<html>
<style type="text/css">
#sheep { color: black; }
#fox { color: brown; }
#boy { color: blue; }
</style>
<body>
<span id="sheep">Baa Baa <a href="#black">Black</aSheep</
span><br/>
<span id="fox">The quick <a href="#brown">brown</afox jumped
over the lazy dog.</span><br/>
<span id="boy">Little boy <a href="#blue">blue</acome blow
your horn.</span><br/>
</body>
</html>

Try modifying your CSS like so:

#sheep, #sheep a { color: black; }
#fox, #fox a { color: brown; }
#boy, #boy a { color: blue; }

User stylesheets, where used, will thwart your scheme, but that''s as it
should be.

Also, your <span>s look like they really ought to be <p>s or <div>s.
Even if you keep them as spans, you could set them to display:block and
specify appropriate margins. In any case, you can get rid of the <br>s.

HTH
--
John


Alan wrote:

I know how to change it so that it is another color, or force it to
NOT have underlining, or make it bold, or italics, or whatever. The
problem is, how do I get it to turn the syling OFF completely. How do
I get it NOT to change the color or text-decoration of the text?

a { color: inherit; text-decoration: inherit; }

--
David
Stardate 7411.5


Alan <ar*****@gmail.comwrites:

Okay, IE and Netscape have a default link style with "color: blue;"
and "text-decoration: underline". That''s fine, but for what I am
doing I need to turn OFF the default styling.

You dona??t explain what you are doing, so instead of proposing a
dysfunctional solution you could just have said

a??I want to turn off the default styling for links.a??

I know how to change it so that it is another color, or force it to
NOT have underlining, or make it bold, or italics, or whatever. The
problem is, how do I get it to turn the syling OFF completely. How do
I get it NOT to change the color or text-decoration of the text?

Removing the HREF attribute works pretty good. Removing the
corresponding tags works even better.

Adding this to the style section doesn''t work (didn''t figure it would,
but it was worth a shot):

a:link { color:none; }
a:visited { color:none; }
a:hover { color:none; }
a:active { color:none; }

It depends on the cost per shot. One could point to the CSS spec, but
Ia??d rather point to the last chapter of a??Surely You''re Joking,
Mr. Feynman!a??.

And adding this to the style section doesn''t work either:

a:link { color:inherit; }
a:visited { color:inherit; }
a:hover { color:inherit; }
a:active { color:inherit; }

And you tried that with a?| ?

You are looking for inherit (no need for the pseudo-classes), but you
are looking with the wrong software.

If you want to err on the safe side,

body,
table,
a
{
color: /* insert RGB value or keyword */;
text-decoration: none;
}

should do the trick with a single rule set.

Most people tend to forget to add

cursor: text

and

outline: none;

to that.

To make it bulletproof you should add something like

<script type="text/javascript">
window.onload = function () {
var a = document.getElementsByTagName(''A''), l = a.length;
while (l--) {
a[l].onclick = function () {
return false;
}
}
}
</script>

(some visitors just wona??t give up, no matter how hard you try to
discourage them)
--
||| hexadecimal EBB
o-o decimal 3771
--oOo--( )--oOo-- octal 7273
205 goodbye binary 111010111011


这篇关于如何获得没有不同颜色的链接。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆