css反转_使用CSS反转颜色

css反转

I've been obsessed lately with finding new or lesser known CSS properties and values and playing around when them.  Some of them are quite useful and others are seemingly only for a giggle.  CSS filters fall in the useful department:  grayscale, blur, sepia -- all common filters.  But how about invert?  And did you know you can invert the color of every element on a page?

最近,我一直迷恋于寻找新的或鲜为人知CSS属性和值,并在它们出现时进行操作。 其中一些功能非常有用,而另一些功能似乎只是在傻笑。 CSS过滤器属于有用的部门: grayscaleblursepia -所有常见的过滤器。 但是反转呢? 而且您知道可以反转页面上每个元素的颜色吗?

CSS (The CSS)

The invert value is percentage-based; 100% fully inverts the colors and 0% displays all colors as normal:

invert值基于百分比; 100%完全反转颜色, 0%正常显示所有颜色:


.normal {
	filter: invert(0%);
}

.inverted {
	filter: invert(100%);
}


You can invert individual elements or, if you invert the document.documentElement, the entire page contents get inverted.  The values reported back by window.getComputedStyle(el) will be the original CSS values, however, so there's no way of getting the true inverted values of given properties.

您可以反转单个元素,或者,如果反转document.documentElement ,则整个页面内容也会反转。 但是,由window.getComputedStyle(el)返回的值将是原始CSS值,因此无法获取给定属性的真实倒置值。

Color inversion is a useful accessibility tool, though it is oftentimes provided by the user's operating system or a separate tool.  I can see inversion being helpful at night, easing eye strain when looking at screens.  Can you think of a good use of color inversion?  Please share!

颜色反转是一种有用的辅助功能工具,尽管它通常由用户的操作系统或单独的工具提供。 我可以看到反转在晚上很有用,可以缓解看屏幕时的眼睛疲劳。 您能想到色彩反转的好用吗? 请分享!

翻译自: https://davidwalsh.name/invert-colors-css

css反转

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值