html - 伪元素的阴影可以留在它的元素后面吗?
问题描述
我遇到的问题是伪元素的阴影 :before 位于其元素的前面。
https://jsfiddle.net/36aqf40y/3/
<div class="rectangle">
<p>Lorem Ipsum</p>
<a href="#" style="color:#FFFFFF">Lorem Ipsum</a>
</div>
<style>
.rectangle {
display: inherit;
position: absolute;
min-width: 200px;
max-width: 400px;
height: 98px;
background-color: #D90030;
z-index: 1;
box-shadow: 3px 3px 5px 0px rgba(0, 0, 0, 0.75);
}
.rectangle:before {
content: " ";
position: absolute;
left: 100%;
border-left: 30px solid #D90030;
border-top: 49px solid transparent;
border-bottom: 49px solid transparent;
filter: drop-shadow(3px 3px 5px rgba(0, 0, 0, 0.75));
}
.rectangle * {
margin: 20px 0 10px 20px;
}
.rectangle p {
font-size: 23px;
color: white;
}
</style>
我真想有.rectangle:before
身后的影子.rectangle
。这样的事情可能吗?
解决方案
采用
filter: drop-shadow(3px 1px 1px rgba(0, 0, 0, 0.75));
代替
filter: drop-shadow(3px 3px 5px rgba(0, 0, 0, 0.75));
.rectangle {
display: inherit;
position: absolute;
min-width: 200px;
max-width: 400px;
height: 98px;
background-color: #D90030;
z-index: 1;
box-shadow: 3px 3px 5px 0px rgba(0, 0, 0, 0.75);
}
.rectangle:before {
top:1px;
content: " ";
position: absolute;
left: 100%;
border-left: 30px solid #D90030;
border-top: 49px solid transparent;
border-bottom: 49px solid transparent;
filter: drop-shadow(3px 1px 1px rgba(0, 0, 0, 0.75));
}
.rectangle * {
margin: 20px 0 10px 20px;
}
.rectangle p {
font-size: 23px;
color: white;
}
<div class="rectangle">
<p>Lorem Ipsum</p>
<a href="#" style="color:#FFFFFF">Lorem Ipsum</a>
</div>
推荐阅读
- google-sheets - 谷歌表格下拉更改自动基于单元格值
- javascript - 对于基于应用程序的在线商店,我应该使用原生应用程序还是混合应用程序
- css - 如何覆盖 Storybook 内容中的降价样式?
- sed - 用 sed 对数字进行分组:下划线对我不起作用
- python - Python正则表达式替换数字-1
- reactjs - 如何从反应中允许python烧瓶socketio中的cors-origin-policy
- django - 如何在外键属性limit_choice_to中使用模型字段名称
- django - 如何使用 django rest 框架根据子数据过滤父数据?
- macos - Big Sur 升级后,Android Studio 显示 NDK 未安装,但它已经安装
- java - 如何使用 Picasso 将 Firebase 中的图像显示到 RecyclerView