为提升您的使用体验,本站正在维护,部分功能暂时无法使用。如果本站文章无法解决您的问题,您想要向社区提问的话,请到 Twitter 上的 @FirefoxSupport 或 Reddit 上的 /r/firefox 提问,我们的支持社区将会很快回复您的疑问。

搜索 | 用户支持

防范以用户支持为名的诈骗。我们绝对不会要求您拨打电话或发送短信,及提供任何个人信息。请使用“举报滥用”选项报告涉及违规的行为。

详细了解

Can I set different link colors for pages with light and dark backgrounds?

  • 6 个回答
  • 0 人有此问题
  • 3 次查看
  • 最后回复者为 Terry

more options

I use userChrome.css and userContent.css to (1) turn unvisited links bright red, and (2) turn visited links bright purple, and (3) add underlines to all links.

This works well on light backgrounds, makes links easy to see and easy to distinguish from other text, but makes them harder to see on pages with dark backgrounds.

Is there a way to vary the link color to improve contrast? I can't use the default colors because most sites use blue links which are hard to distinguish from black text.

I use userChrome.css and userContent.css to (1) turn unvisited links bright red, and (2) turn visited links bright purple, and (3) add underlines to all links. This works well on light backgrounds, makes links easy to see and easy to distinguish from other text, but makes them harder to see on pages with dark backgrounds. Is there a way to vary the link color to improve contrast? I can't use the default colors because most sites use blue links which are hard to distinguish from black text.

所有回复 (6)

more options

P.S. I already use a 1 pixel blur-shadow to bolden all text on Firefox on Linux Mint. If it's possible to use 2 shadows, I could perhaps use a white 5 px blur behind links, with a font-colored 1 px blur on top of that, with the font on top as usual.

more options

Hi Marja, it depends. Some sites are themed based on a signal from the browser about whether you prefer a light or dark theme. This would be one way to decide what text/background colors to apply to links. More info: https://developer.mozilla.org/docs/Web/CSS/@media/prefers-color-scheme

But some sites use a dark or light theme regardless of your browser's expressed preference, so in that case, you would need a script that can detect the appearance of the page in order to choose the best color scheme.

Are you currently using text-shadow? You can layer shadows starting from different positions, but it still has some transparency so this isn't very nice:

text-shadow: #eee -10px -5px 20px, #eee 10px 5px 20px, #eee -10px 5px 20px, #eee 10px -5px 20px;

Although it gives the link a crude appearance, what about a simple background color?

background-color: #ffe !important; border-radius: 4px;

Hopefully that won't be too blinding on dark-themed sites.

more options

There is text-shadow and box shadow that supports multiple colors apart from an outline, so you can possibly use a set for dark and white.

I'm not sure what is best in your case, so my try at subreddit FirefoxCSS.

more options

Note that websites can use an image as a clickable link (i.e. no text), so be cautious with using !important to override background-color as this can cause images to disappear.

more options

Thanks. I've tried the background color. It's a bit too intense. I think something which halfway lightens the backgrounds might work better.

more options

There's a user script called NoBrighter on greasyfork .org which may suit you. It is very simple to configure.