html - 有没有办法逃避剪辑路径 : from child elements? 相对于剪辑背景定位的 I.E 图像也被剪辑

标签 html css svg

我正在尝试将 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>

关于html - 有没有办法逃避剪辑路径 : from child elements? 相对于剪辑背景定位的 I.E 图像也被剪辑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54796153/

相关文章:

html - 从 Google Chrome 打印时的页码

javascript - 在 HTML 表单中使用自动生成的(即随机的)ID

html - 如何禁用 HTML 中大字的表格大小调整

html - 在隐藏的 div 中并排显示 2 个表单按钮

javascript - 带有图像 slider 的汉堡菜单

javascript - 调整窗口大小时重新加载 JavaScript 动画

javascript - 当 url 包含特定参数时隐藏页眉/页脚

css - 如何在 div 中居中放置 SVG?

javascript - 无法在 IE 中更改 SVG innerHTML

javascript - RaphaelJS 中对象的渐变透明度