我试图将 SVG 图像放置在与另一个背景有视差的剪裁背景上。我希望 SVG 一半在背景上,一半在前景上,但它会使用剪辑路径与背景一起被剪辑。我是否可以使用另一种方法来实现无需裁剪 SVG 的效果,或者是否有方法可以禁用继承的效果?请记住,我想保持它相对于这个背景的位置。
CSS 有问题
.content
{
height: 300vh;
min-height: 150vh;
background: #25282A;
clip-path: polygon(-400% 100%, 100% 100%, 100% 10%);
position: relative;
z-index: 1;
}
.content img{
position: relative;
top: 20vh;
left: 2vw;
z-index: 3;
}
HTML
<section class="content">
<img src="/Asssets/RWR food image.jpg">
<img src="/Assets/Title.svg" />
</section>
您需要考虑另一种选择clip-path
将剪辑该元素及其所有内容。
由于它与背景有关,因此您可以依靠如下所示的渐变来创建类似的效果。
.content {
height: 300vh;
min-height: 150vh;
background:
/*a triangle shape offested by 50px from the top taking 25% of the height*/
linear-gradient(to bottom right,transparent 49.8%,#25282A 50%) 0 50px/100% 25%,
/*fill the remaining (75% - 50px) with solid color*/
linear-gradient(#25282A,#25282A) bottom/100% calc(75% - 49px);
background-repeat:no-repeat;
}
<div class="content">
</div>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)