gpt4 book ai didi

html - 在图像上添加不透明度

转载 作者:搜寻专家 更新时间:2023-10-31 23:21:12 26 4
gpt4 key购买 nike

我要开门见山了。我想在图像中创建一个简单的窗口。窗外会有像示例图片一样的不透明度。

我不太擅长 css,所以请多多包涵。

.section2{
}

.section2 .row{
margin: 0;
}
.the-container{
position: relative;
width: 100%;
height: 450px;
}
.the-container .text-center{
background: #fff;
opacity: .9;
}

.img-canvas{
position: absolute;
top: 0px;
left: 0px;
right: 0px;
bottom: 0px;
width: 100%;
height: 100%;
background-image: url(https://www.aman.com/sites/default/files/styles/1371x706/public/amanpulo-location-1200-x-825.jpg?itok=4BQy9j-X);
background-size: 100% 100%;
background-position: 50% 50%;
background-attachment: scroll;
z-index: -1;
}
.window{
position:absolute;
width:50%;
height:50%;
background-size: cover;
top:0;
left:25%;
z-index: -1;
opacity: 1;
}
<section class="section2" style="height:100vh;">
<div class="row">
<div class="col-md-10 col-md-offset-1">
<div class="the-container">
<div class="img-canvas"></div>
<div class="window"></div>
</div>
</div>
</div>
</section>
是这样的: enter image description here

这里有一个 fiddle 供您操作代码: https://jsfiddle.net/Lk21vL01/

提前致谢。

最佳答案

你已经非常接近了,你只需要对你的 .window 元素应用类似的样式并使用 background-attachment:fixed

看这个updated jsfiddle

.section2{
}

.section2 .row{
margin: 0;
}
.the-container{
position: relative;
width: 100%;
height: 450px;
}
.the-container .text-center{
background: #fff;
opacity: .9;
}
.window,
.img-canvas{
position: absolute;
top: 0px;
left: 0px;
right: 0px;
bottom: 0px;
width: 100%;
height: 100%;
background-image: url(https://www.aman.com/sites/default/files/styles/1371x706/public/amanpulo-location-1200-x-825.jpg?itok=4BQy9j-X);
background-size: 100% 100%;
background-position: 50% 50%;
background-attachment:fixed;
z-index: -1;
opacity: 0.5;
}
.window{
position:absolute;
width:50%;
height:50%;
top:0;
left:25%;
z-index: -1;
opacity: 1;
}

关于html - 在图像上添加不透明度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40797533/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com