css - 封面背景图+渐变背景

标签 css background-image gradient

我现在正在构建一个网站,并尝试设置一个带有背景图像的部分以覆盖生成的所有部分和渐变背景。 我尝试将它们放在一起但它并没有真正起作用,这就是我尝试过的: https://jsfiddle.net/gmtujnmh/

#fullcover {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-size: cover;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-position: center;
  max-height: 60%;
  display: inline;
  background-image: url(http://www.materials-world.com/bricks/belden/whites/images/AlaskaWhiteVelourWT.jpg);
  /* fallback */
  background: rgba(62, 21, 49, 1);
  background: -moz-linear-gradient(-45deg, rgba(62, 21, 49, 1) 0%, rgba(162, 23, 128, 1) 100%);
  background: -webkit-gradient(left top, right bottom, color-stop(0%, rgba(62, 21, 49, 1)), color-stop(100%, rgba(162, 23, 128, 1)));
  background: -webkit-linear-gradient(-45deg, rgba(62, 21, 49, 1) 0%, rgba(162, 23, 128, 1) 100%);
  background: -o-linear-gradient(-45deg, rgba(62, 21, 49, 1) 0%, rgba(162, 23, 128, 1) 100%);
  background: -ms-linear-gradient(-45deg, rgba(62, 21, 49, 1) 0%, rgba(162, 23, 128, 1) 100%);
  background: linear-gradient(135deg, rgba(62, 21, 49, 1) 0%, rgba(162, 23, 128, 1) 100%);
  filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#3e1531', endColorstr='#a21780', GradientType=1);
}
<div id="fullcover"></div>

它从 cssmatic 中获取的渐变代码,有人可以帮助我吗?

最佳答案

您的 fiddle 中的代码与您在此处发布的代码不匹配,此答案适用于 fiddle 中的代码。

你需要给渐变添加一些不透明度,它为我解决了这个问题,这里有一个 fiddle 给你:

https://jsfiddle.net/gmtujnmh/2/

#fullcover{
    position: absolute;
    top: 0; 
    left: 0;
    right: 0;
    bottom: 0;
    background-size: cover;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-position: center;
    max-height: 60%;
    display:inline;

    background-image: url(http://www.materials-world.com/bricks/belden/whites/images/AlaskaWhiteVelourWT.jpg); /* fallback */

background-image: -webkit-gradient(
  linear, left top, left bottom, from(rgba(62,21,49,.6)),
  to(rgba(162,23,128,.9)), color-stop(.5,#333333)
), url(http://www.materials-world.com/bricks/belden/whites/images/AlaskaWhiteVelourWT.jpg); /* Chrome 10+, Saf5.1+ */

现在您只需调整颜色和不透明度即可获得您想要的效果,希望对您有所帮助。

关于css - 封面背景图+渐变背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39362100/

相关文章:

CSS3 - 带有背景图像的交叉淡入淡出图像

css - 背景大小 : contain across different screen

css - 如何从我的 wordpress 网站中的 iframe 中删除 png 透明度

jquery - 带有 Masonry 堆叠的顶部/底部边距

css3 div 和 anchor 标签倾斜变换在不同的边

html - 背景 : url(), 背景图像:url() 不工作

用于样式化 SVG 元素的 CSS 3 渐变

python-3.x - 在 tensorflow 中计算梯度返回什么

jquery css,css 渐变

jquery - 使用 jquery 在特定(位置)div 加载页面