javascript - 有没有办法通过底层组件层进行射线照相
问题描述
任务描述:
有一个元素包含另一个元素,而另一个元素又包含另一个元素(理论上可以有一系列内部元素)。最后一个元素的背景设置为透明。任务是这种透明度将一直下降到第一个外部元素的背景。
因此,在下面的示例中,.shouldRadiographElement 区域的背景应该是黄色的,作为 .wrapper 元素的背景。
如果需要对任务进行一些澄清,请在评论中提问。
.wrapper {
width: 200px;
height: 200px;
background: yellow;
}
.element {
width: 100px;
height: 100px;
background: green;
}
.shouldRadiographElement {
width: 50px;
height: 50px;
border: 1px solid white;
background: transparent;
}
<div class="wrapper">
<div class="element">
<div class="shouldRadiographElement"></div>
</div>
</div>
解决方案
您可以在第二个 Div 上使用 Clip-path 属性,如下所示
.wrapper {
width: 200px;
height: 200px;
background: yellow;
}
.element {
width: 100px;
height: 100px;
background: green;
clip-path: polygon(0% 0%, 0 54%, 0 55%, 0 0, 55% 0, 56% 53%, 0 53%, 0 100%,
100% 100%, 100% 0%);
}
.shouldRadiographElement {
width: 50px;
height: 50px;
border: 1px solid white;
background: transparent;
}
<div class="wrapper">
<div class="element">
<div class="shouldRadiographElement"></div>
</div>
</div>
推荐阅读
- laravel - 无法访问 API | Laravel
- visual-studio-2019 - 抑制 VS 数据库项目中的引用错误不起作用
- postman - 如何在邮递员中编写嵌套测试用例?
- docusignapi - 我们应该在我们的 DocuSign API 集成中使用什么类型的身份验证
- ruby-on-rails - 无法运行 wicked_pdf
- loopback4 - loopback4 休息连接器多次调用
- html - 垂直和水平 Flexbox 容器对齐
- javascript - 无法在方法中使用 array.map 获取要在下拉列表中呈现的标签
- c++ - 哪些崩溃情况会导致崩溃转储?
- java - 如何在 Android WebView 中正确实施 AdMob 插页式广告?