Radial gradient opacity on background image

流过昼夜 提交于 2019-12-24 07:48:29

问题


I need to apply a radial gradient of opacity to a repeating background image.

The proposed solutions online recommend to add another solid color gradient over the image giving the illusion of a fading background image. However, this solid color gradient solution will not work in my case because the background is not a solid color, but rather a linear gradient.

Here is an exaggerated example of what I'm trying to achieve using a bright red repeating background image and a grey to black gradient background.

How can I actually fade a background image?


回答1:


Use mask

.box {
  width:300px;
  height:200px;
  background:url(https://picsum.photos/id/10/600/800) center/cover;
  -webkit-mask:radial-gradient(circle at 20% 40%, transparent , #fff 50%);
  mask:radial-gradient(circle at 20% 40%, transparent , #fff 50%);
}

body {
 background:pink;
}
<div class="box">

</div>


来源:https://stackoverflow.com/questions/58071243/radial-gradient-opacity-on-background-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!