简体   繁体   English

应用玫瑰色或更改css / js / jquery / html中整个文档的亮度?

[英]apply a rose tint or change entire documents brightness in css/js/jquery/html?

Is there a better practice for achieving this? 是否有更好的方法来实现这一目标? Currently I'm using an opaque red div of width/height 100%, higher z-index and pointer-events: none which allows everything underneath to work. 目前,我正在使用宽度/高度为100%,z-index和指针事件较高的不透明红色div:无,这不允许所有内容正常工作。

Also I'd like to be able to dim the entire document, is there any sort of brightness property I could apply or would I again be better off putting an opaque black layer over everything? 另外,我希望能够调暗整个文档的亮度,是否可以应用某种亮度属性,还是最好在所有物体上放置一个不透明的黑色层?

Just wondering if I'm going about this the wrong way. 只是想知道我是否会以错误的方式进行操作。 I'd also be interested in js/jquery solutions if they were more efficient, I'm not bothered about compatibility with older browsers either. 如果它们效率更高,我也会对js / jquery解决方案感兴趣,我也不担心与旧版浏览器的兼容性。

** If anyone could tell me the easiest way to make everything black and white also I'd really appreciate it. **如果有人能告诉我最简单的方法来使所有东西变成黑色和白色,我也将不胜感激。

A WebKit-only feature: 仅限WebKit的功能:

-webkit-filter: grayscale; /* Turn everything black and white */
-webkit-filter: brightness(20%); /* Make stuff brighter */

You can use hue-rotate to change the hue, depending on what your general color scheme is. 您可以使用hue-rotate更改色调,具体取决于您的常规配色方案。 If it's all different, you'll need a custom filter, which is more difficult and which I'm in the process of doing now. 如果两者都不一样,那么您将需要一个自定义过滤器,该过滤器会比较困难,并且我现在正在处理中。

Here's more information. 这是更多信息。

You can use 您可以使用

body {
 opacity: 0.8; // Any value between 0 & 1 where is 0 in invisible & 1 is 100% opaque
 }

But since that would be on white background I am not sure it would give you desired output. 但是由于那将是白色背景,所以我不确定它是否会为您提供所需的输出。 If you wish to add color filter to entire screen, you'll have to add overlay and like you said none of the stuff underneath won't work. 如果您想在整个屏幕上添加滤色器,则必须添加覆盖,就像您说的那样,下面的东西都不起作用。

-webkit- CSS attributes would work only for Chrome & safari. -webkit- CSS属性仅适用于Chrome和Safari。

...is there any sort of brightness property I could apply or would I again be better off putting an opaque black layer over everything? ...是否可以应用某种亮度属性,还是最好在所有物体上放置一个不透明的黑色层?

The easiest way would be: $('body').css('opacity', '0.3'); 最简单的方法是: $('body').css('opacity', '0.3'); . If you want to change background color you can apply that to the html-node: $('html').css('background', '#000'); 如果要更改背景颜色,可以将其应用于html节点: $('html').css('background', '#000');

** If anyone could tell me the easiest way to make everything black and white also I'd really appreciate it. **如果有人能告诉我最简单的方法来使所有东西变成黑色和白色,我也将不胜感激。

In Internet Explorer you can use windows filters . 在Internet Explorer中,您可以使用Windows过滤器 Use -webkit-filter: grayscale; 使用-webkit-filter: grayscale; for Chrome/Safari. 适用于Chrome / Safari。 It might be possible to achieve in Mozilla and Opera as well, but I'm not sure. 也可能在Mozilla和Opera中实现,但我不确定。

It looks like you want the entire page (including "underlying" DOM elements) to be a particular hue, which is not possible by just changing the body color or opacity. 看起来您希望整个页面(包括“底层” DOM元素)成为特定的色相,而仅通过更改主体颜色或不透明度是不可能的。 What you want is something like the BlockUI plugin for jQuery. 您想要的是类似jQuery的BlockUI插件。 If I'm not mistaken there is an option to still allow the user to interact with page elements when the UI is "blocked". 如果我没记错的话,当UI被“阻止”时,还有一个选项仍然允许用户与页面元素进行交互。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM