【发布时间】:2017-08-05 10:13:51
【问题描述】:
我需要在背景图像底部使用这种类型的渐变
我不知道如何使用 CSS 使这种类型渐变。我已将代码上传到jsFiddle。
.single-blog-bg {
background-size: cover;
background-attachment: fixed;
height: 350px;
position: relative;
}
.single-blog-bg:before {
content: '';
position: absolute;
left: 0;
right: 0;
top: 300px;
bottom: 0;
background: linear-gradient(to bottom, white 10%, white 30%, white 60%, white 100%);
opacity: .5;
}
<div class="single-blog-bg" style="background-image: url(https://i.stack.imgur.com/VT8SR.jpg)"></div>
这里显示白色渐变,但与我预期的不一样。
有没有人可以帮我获取准确的 CSS 代码?
【问题讨论】:
-
JS Fiddle 链接-jsfiddle.net/sLhf9on0/2
-
codepen 链接-codepen.io/djmayank/pen/vJyoVe
-
渐变和图片可以同时设置。首先是渐变,然后是图片。 jsfiddle.net/sLhf9on0/5
-
渐变(从上到下)透明到白色
标签: html css linear-gradients