覆盖主要超链接,即:链接 [英] Overriding the Main Hyperlinks, i.e. a:link

查看:119
本文介绍了覆盖主要超链接,即:链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如何覆盖页面上的超链接设置,如颜色和下划线等?例如,对于与我的标准链接在同一页面上的某些链接,我想将它们设为黑色而不是我对所有超链接的标准红色。所以这些将存在于同一页面上。我听说创建一个内联样式可能是解决方案,但这是唯一的方法吗?我要问的原因是我必须为多个页面执行此操作,并且在每个页面上创建新的内联样式会变得很麻烦。

提前感谢,Stacey

Hi,

How do I override my hyperlink settings such as the colors and underlines, etc. on a page?  For example, for certain links on the same page as my standard links, I would like to just make them black instead of the standard red color I have for all hyperlinks.  So these would exist on the same page.  I heard that creating an in-line style might be the solution but is that the only way?  Reason I am asking is that I have to do this for multiple pages and it gets cumbersome creating a new in-line style on each page.

Thank you in advance,
Stacey

推荐答案

没问题。 CSS的强大功能在您的竞标中。 ;-)

所有你需要做的就是使用后代选择器。通过这个,我的意思是,对于你希望a:link伪类具有不同颜色的那些区域,在它的容器的选择器后面声明它。

例如,让我们说你的所有正常在浅色背景上链接很暗,但你有一个黑色的页脚,所以很难看到它们。如果你给了页脚id'footer',声明a:这样的链接属性

#footer a:link {
color:white; / *或红色,或浅绿色,或任何你想要的东西* /
}

这对CSS解析器说的是为所有链接元素白色的子元素(即由其包含)着色。只有那些包含的链接才会是白色的。所有其他将保持默认或您之前声明的任何颜色。

请注意,不需要提供其他特征。除非特别重写,否则先前声明的任何属性(font-family,font-size等)将保持有效。因此,您的页脚链接将显示为您的其他链接,只有足够亮以便可见。此外,由于您在外部样式表中声明了这一点,它将适用于所有页面上的所有类似元素,而不需要内联样式。

欢呼,
scott
Not a problem. The power of CSS is at your bidding.  ;-)

All you have to do is use descendant selectors. By this, I mean that for those areas where you wish to have a different color for the a:link pseudo-class, declare it following the selector for its container.

For example, let's say all of your normal links are dark on a light background, but you have a dark footer, so they would be hard to see. If you have given the footer the id "footer," declare the a:link properties like this

#footer a:link {
    color:white;   /* or red, or aqua, or whatever you want */
}

What this says to the CSS parser is to color all links which are children of (i.e. contained by) the footer element white. Only those links which are so contained will be colored white. All others will remain at the default or whatever color you have earlier declared.

Note also that there is no need to provide other characteristics. Any properties previously declared (font-family, font-size, etc.) will remain in force unless specifically overridden. So, your footer links will appear just as your other links, only light enough to be seen. Also, since you declare this in your external stylesheet, it will apply to all similar elements on all pages, with no need for inline styling at all.

cheers,
scott


这篇关于覆盖主要超链接,即:链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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