Javascript - “深一点”
是否可以使用javascript来确定什么颜色比当前背景暗一号?也许一些十六进制加法/减法?
我有一个可以是任何颜色的菜单,如果不是太困难的话,如果子菜单可以深一点就更好了。有谁知道如何达到这个效果?
Is it possible to use javascript to determine what color is one shade darker than the current background? Maybe some hexadecimal addition/subtraction?
I have a menu that can be any color and if it wasn't too difficult it would be great if the submenu could be one shade darker. Does anyone know how to achieve this effect?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
像这样的东西:
用法:
这是一个测试它的示例代码:http://pastebin.com/g6phySEv
Something like this:
Usage:
Here is an example code to test it: http://pastebin.com/g6phySEv
正如 AB 所评论的,“阴影”的定义并不明确。尽管如此,用其他颜色表示可能更容易想到这一点,例如 hsv< 中的“V” /a>.
您可以转换、减少 v 并转换回来,或者找出减少 v 在 rgb 十六进制中映射到什么
as AB comments, 'shade' isn't very well defined. nonetheless, it might be easier to think of this in some other colour representation, such as 'V' in hsv.
you could either convert, decrease v and convert back, or figure out what decreasing v maps to in rgb hex