200字范文,内容丰富有趣,生活中的好帮手!
200字范文 > html 修改背景透明度 html – 用css更改背景图像的不透明度

html 修改背景透明度 html – 用css更改背景图像的不透明度

时间:2023-06-09 12:00:56

相关推荐

html 修改背景透明度 html – 用css更改背景图像的不透明度

您可以在Photoshop或GIMP等程序中更改不透明度.

或者你可以用css中的不透明度来做到这一点.但是你可能不希望这样,因为你的.intro中会有一些内容,然后它也会受到影响.

所以我建议遵循解决方案

.intro {

position: relative;

z-index: 0;

display: table;

width: 100%;

height: auto;

padding: 100px 0;

text-align: center;

color: black;

background-color: transparent;

-webkit-background-size: cover;

-moz-background-size: cover;

background-size: cover;

-o-background-size: cover;

}

.intro:after {

content : "";

display: block;

position: absolute;

top: 0;

left: 0;

background: url('/static/images/canberra_hero_image.jpg');

background-size: cover;

width: 100%;

height: 100%;

opacity : 0.2;

z-index: -1;

}

基本上你添加:在作为背景图像的元素之后,你将它定位为绝对(你的.intro将需要位置:相对;)然后你设置z-index和不透明度.

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。