css - 使用渐变生成饱和度/亮度蒙版

我想知道是否有可能生成饱和度+亮度的掩码,例如在颜色选择器中使用(类似于 http://johndyer.name/lab/colorpicker/refresh_web/colorpicker/images/map-hue.png )但在 css3 中仅使用线性渐变? 我尝试了几件事,例如:

background: linear-gradient(to right, hsla(0,100%,0,0) 0%, hsla(0,0%,0%,.5) 100%), /* saturation mask */
            linear-gradient(to top, hsla(0,0%,0%,.5) 0%, hsla(0,0%,100%,.5) 100%), /* lightness mask */

但是我做不出像图片这样的东西,找不到合适的组合,而且因为我不是很了解,所以我不知道是否可以。

谢谢

最佳答案

这可能是你写的方式。

  1. 对于图像,1 个渐变 + 背景色即可。
  2. 你没有正确关闭你的规则,仍然需要一个值 100%) , /* li :)
  3. 可能是这样:
ele {
background: 
    linear-gradient(0deg, hsla(0,0%,0%,.5) 0%, hsla(0,0%,100%,.5) 100%) no-repeat left ,
    white   linear-gradient(180deg, hsla(0,0%,0%,.5) 0%, hsla(0,0%,100%,.5) 100%) no-repeat right;
    background-size:95% 100%, 5% 100%;
}

http://codepen.io/anon/pen/ubDsr (渐变覆盖 body )

https://stackoverflow.com/questions/17224383/

相关文章:

database - 是否有任何工具可以从数据库模式的 json 表示自动生成 ERD 图?

android-layout - 在滑动选项卡中水平滚动 : android

json - 将 JSON 数据加载到大查询中时出错 : flat value specified

ruby-on-rails - rails 和 Heroku : Running a script

linux - 为什么我得到数据大小大于 mss 的数据包?

c++-cli - 导出 C++/CLI native 类 (C4679)

ajax - 我可以添加 Access-Control-Allow-Origin : * to th

macos - 运行 make 时如何修复 ranlib/libtool 错误

python - 从 Python 中的角度集生成多边形?

nginx - 如何替换 HTTP 请求 URI 中的特殊字符?