是否有一个HTML代码可以使我的背景图片透明和我的文本不透明?
好的,我一直在为一门技术课输入一些HTML代码,我需要满足我教育专业的要求。这就是我的背景:是否有一个HTML代码可以使我的背景图片透明和我的文本不透明?,html,css,background-image,Html,Css,Background Image,好的,我一直在为一门技术课输入一些HTML代码,我需要满足我教育专业的要求。这就是我的背景: body { background-image:url('islandbeach.jpg'); background-repeat:repeat; background-position:center; background-attachment:fixed; background-size:cover; } 现在,我想使我的背景透明或褪色,这样我就可以看到文本
body {
background-image:url('islandbeach.jpg');
background-repeat:repeat;
background-position:center;
background-attachment:fixed;
background-size:cover;
}
现在,我想使我的背景透明或褪色,这样我就可以看到文本和其他图像,我有。背景太鲜艳了,不必眯着眼睛就能看到单词。有没有HTML代码可以帮我做到这一点?我不是这方面的专家,我只是按照教授告诉我的去做。如果你有答案,请用小步骤解释一下。非常感谢你 下面是一个简单的hack,您可以使用:after属性进行操作 Css代码
body:after {
content: "";
background-image:url('http://www.w3schools.com/css/klematis.jpg');
background-repeat:repeat;
background-position:center;
background-attachment:fixed;
background-size:cover;
opacity: 0.5;
top: 0;
left: 0;
bottom: 0;
right: 0;
position: absolute;
z-index: -1;
}
js-bin演示
试试这个
.bg {
width:280px;
height:100px;
position:relative;
display:block;
}
.bg:after {
background: url(https://www.google.co.in/images/srpr/logo3w.png);
opacity: .5;
width:280px;
height:100px;
top: 0;
left: 0;
position: absolute;
z-index: -1;
content: "";
}
这里有一个选项1:使用褪色的背景,这样你将要写的文本或你使用的图像将是可读的 选项2:你的身体标签上有图像和带有bgopc类的div,它将位于带有白色和降低不透明度的图像和div之上。。。因此,您的图像将变得透明。现在,另一个id为container的div将充当图像和内容的容器
<body>
<div class="bgopc"> </div>
<div id=container>Add your Text and Images inside this container </div>
</body>
我希望它能解决你的问题。Cool:)关键是使用CSS“z-index”来利用+1:好问题:我学到了一些东西!谢谢:)
body {background-image:url('islandbeach.jpg');background-repeat:repeat;background-position:center;background-attachment:fixed;background-size:cover;}
.bgopc{max-height:100%;background:#fff;position:absolute;top:0;left:0;width:100%;
height:100%;opacity:0.4;filter:alpha(opacity=40);z-index:1}
#container{z-index:2;position:relative}