Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/82.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 不影响文本的背景图像不透明度_Html_Css_Background Image_Opacity - Fatal编程技术网

Html 不影响文本的背景图像不透明度

Html 不影响文本的背景图像不透明度,html,css,background-image,opacity,Html,Css,Background Image,Opacity,我的背景图像和文本有问题。我只想应用不透明的背景图像,但我的,文本受到影响 HTML 没有“背景不透明度”属性,但可以使用“伪元素”对其进行伪造: .content { position: relative; } .content::after { content: ""; background: url(../img/103_n.jpg) left top no-repeat, url(../img/103_n.jpg) right bottom no-repeat; opa

我的背景图像和文本有问题。我只想应用不透明的背景图像,但我的,文本受到影响

HTML


没有“背景不透明度”属性,但可以使用“伪元素”对其进行伪造:

.content {
  position: relative;
}

.content::after {
  content: "";
  background: url(../img/103_n.jpg) left top no-repeat, url(../img/103_n.jpg) right bottom no-repeat;
  opacity: 0.5;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  position: absolute;
  z-index: -1;   
}

没有“背景不透明度”属性,但可以使用“伪元素”对其进行伪造:

.content {
  position: relative;
}

.content::after {
  content: "";
  background: url(../img/103_n.jpg) left top no-repeat, url(../img/103_n.jpg) right bottom no-repeat;
  opacity: 0.5;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  position: absolute;
  z-index: -1;   
}
点击这个链接

.content{
位置:相对位置;
}
.内容::之后{
内容:“;
背景:url('https://images.pexels.com/photos/259915/pexels-photo-259915.jpeg“)左上角不重复,url('https://images.pexels.com/photos/259915/pexels-photo-259915.jpeg右下角不重复;
不透明度:0.5;
排名:0;
左:0;
底部:0;
右:0;
位置:绝对位置;
z指数:-1;
}

知识是一种美德,是一种美德,是一种美德,是一种美德

点击此链接

.content{
位置:相对位置;
}
.内容::之后{
内容:“;
背景:url('https://images.pexels.com/photos/259915/pexels-photo-259915.jpeg“)左上角不重复,url('https://images.pexels.com/photos/259915/pexels-photo-259915.jpeg右下角不重复;
不透明度:0.5;
排名:0;
左:0;
底部:0;
右:0;
位置:绝对位置;
z指数:-1;
}

知识是一种美德,是一种美德,是一种美德,是一种美德

您可以使用before(或)after并设置不透明度

    .content {
      position: relative;
    }

    .content ::after {
    content: "";
    position: absolute;
    background:#000 \also give any color for background;
    opacity: 0.5;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    width:100%;
    height:100%;  
    }
可以使用before(或)after并设置不透明度

    .content {
      position: relative;
    }

    .content ::after {
    content: "";
    position: absolute;
    background:#000 \also give any color for background;
    opacity: 0.5;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    width:100%;
    height:100%;  
    }

为了能够将父级不透明度与其子级分开,需要为父级使用伪选择器:

.content:after {
    content: '';    
    background: url(../img/103_n.jpg) no-repeat, url(../img/103_n.jpg) right bottom no-repeat;
    opacity: 0.5;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

为了能够将父级不透明度与其子级分开,需要为父级使用伪选择器:

.content:after {
    content: '';    
    background: url(../img/103_n.jpg) no-repeat, url(../img/103_n.jpg) right bottom no-repeat;
    opacity: 0.5;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

您是否尝试过将内容的z索引设置为-1,然后将文本的z索引设置为1,使您的文本位置相对。@Laljitadani您附加的链接使用的是
背景色
,我不需要让我的背景编辑opacity@Ven2.使用定位。您是否尝试过将内容的z索引设置为-1,然后将文本的z索引设置为1,使文本的位置相对。@LaljiTadhani您附加的链接使用的是
背景色
,我不需要让我的背景编辑opacity@Ven2.使用定位。您应该投票关闭duplicate@Hien阮:谢谢,它运行得很好。你应该投票关闭它duplicate@Hien阮:谢谢,很好用。