Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/90.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 使用CSS3的背景图像底部梯度_Html_Css_Linear Gradients - Fatal编程技术网

Html 使用CSS3的背景图像底部梯度

Html 使用CSS3的背景图像底部梯度,html,css,linear-gradients,Html,Css,Linear Gradients,我需要这种类型的梯度在背景图像的底部 我想不出-我如何用CSS来制作这种渐变。我已经上传了我的代码 。单个博客背景{ 背景尺寸:封面; 背景附件:固定; 高度:350px; 位置:相对位置; } .单个博客背景:以前{ 内容:''; 位置:绝对位置; 左:0; 右:0; 顶部:300px; 底部:0; 背景:线性梯度(至底部,白色10%,白色30%,白色60%,白色100%); 不透明度:.5; } 使用背景:线性渐变(至底部,rgba(255255,0),白色100%)用于底部div 我用

我需要这种类型的梯度在背景图像的底部

我想不出-我如何用CSS来制作这种渐变。我已经上传了我的代码

。单个博客背景{
背景尺寸:封面;
背景附件:固定;
高度:350px;
位置:相对位置;
}
.单个博客背景:以前{
内容:'';
位置:绝对位置;
左:0;
右:0;
顶部:300px;
底部:0;
背景:线性梯度(至底部,白色10%,白色30%,白色60%,白色100%);
不透明度:.5;
}

使用
背景:线性渐变(至底部,rgba(255255,0),白色100%)用于底部
div


我用你的jsfiddle。

使用
背景:线性渐变(到底部,rgba(255255,0),白色100%)用于底部
div


我用你的JSFIDLE。

你可以像这样使用背景

background: linear-gradient(to bottom, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%);

检查此处

您可以像这样使用背景

background: linear-gradient(to bottom, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%);

检查此处

是否尝试在颜色中使用alpha

将渐变规则更改为类似以下内容:

.single-blog-bg:before{
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 100px;
  bottom: 0;
  background: linear-gradient(to bottom,  rgba(255,255,255,0) 10%, rgba(255,255,255,0.9) 100%);
}

编辑:删除不透明度属性,更改底部颜色alpha并使效果更高

您尝试过在颜色中使用alpha吗

将渐变规则更改为类似以下内容:

.single-blog-bg:before{
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 100px;
  bottom: 0;
  background: linear-gradient(to bottom,  rgba(255,255,255,0) 10%, rgba(255,255,255,0.9) 100%);
}
编辑:删除不透明度属性,更改底色alpha并使效果更高

尝试更改css- 我为你做了什么

.single-blog-bg {
    background-size: cover;
    background-attachment: fixed;
    height: 350px;
    position: relative;    
}
.single-blog-bg:before{
    content: '';
    position: absolute;
  display: flex;
    left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  background: linear-gradient(to bottom, rgb(0, 0, 0) 30%, rgb(255, 255, 255) 100%);
  opacity: .5;
}
请检查-

尝试更改css- 我为你做了什么

.single-blog-bg {
    background-size: cover;
    background-attachment: fixed;
    height: 350px;
    position: relative;    
}
.single-blog-bg:before{
    content: '';
    position: absolute;
  display: flex;
    left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  background: linear-gradient(to bottom, rgb(0, 0, 0) 30%, rgb(255, 255, 255) 100%);
  opacity: .5;
}
一定要检查-

。单个博客背景{
背景尺寸:封面;
背景附件:固定;
高度:350px;
位置:相对位置;
}
.单个博客背景:以前{
内容:'';
位置:绝对位置;
左:0;
右:0;
/*顶部:300px*/
底部:0;
背景:线性梯度(到顶部,rgba(255,255,255,0.95)10%,rgba(255,255,255,0.13)60%,rgba(255,255,255,0.04)70%);
/*不透明度:.5*/
身高:100%;
}
不透明度:.5;
}

。单个博客背景{
背景尺寸:封面;
背景附件:固定;
高度:350px;
位置:相对位置;
}
.单个博客背景:以前{
内容:'';
位置:绝对位置;
左:0;
右:0;
/*顶部:300px*/
底部:0;
背景:线性梯度(到顶部,rgba(255,255,255,0.95)10%,rgba(255,255,255,0.13)60%,rgba(255,255,255,0.04)70%);
/*不透明度:.5*/
身高:100%;
}
不透明度:.5;
}

将此样式添加到图像:

mask-image: linear-gradient(to bottom, rgba(0,0,0,1), rgba(0,0,0,0));
-webkit-mask-image: -webkit-gradient(linear, left top, left bottom, from(rgba(0,0,0,1)), to(rgba(0,0,0,0)));

将此样式添加到图像:

mask-image: linear-gradient(to bottom, rgba(0,0,0,1), rgba(0,0,0,0));
-webkit-mask-image: -webkit-gradient(linear, left top, left bottom, from(rgba(0,0,0,1)), to(rgba(0,0,0,0)));

JS Fiddle链接-codepen链接-可以同时设置渐变和图像。首先是梯度,然后是图片。渐变(从上到下)透明到白色JS FIDLE链接-codepen链接-渐变和图像都可以一起设置。首先是梯度,然后是图片。渐变(从上到下)透明到白色谢谢你的回答。但是梯度需要更多的高度-谢谢你的回答。但是梯度需要更多的高度-需要更多的梯度高度。这意味着它应该覆盖更多的区域。@user7329515更改
top:100px
以增加它的高度。使用ChangeRequired编辑响应需要更高的渐变高度。这意味着它应该覆盖更多的区域。@user7329515更改
top:100px
以增加它的高度。编辑带有更改的响应