gpt4 book ai didi

css - svg 过滤器阴影路径修复

转载 作者:行者123 更新时间:2023-11-28 11:55:48 25 4
gpt4 key购买 nike

如何修复阴影之间的间隙?我希望阴影是连续的,而不是断断续续的。阴影应该在一条黑线上,没有任何空格

这是我的例子:

.wave-container {
position: absolute;
width: 100%;
height: 100%;
color: #fff;
padding: 8px;
padding-bottom: 50px;
display: flex;
flex-direction: column;
justify-content: center;
text-align: center;
overflow: hidden;
background-color: #ccc;
}
.wave-container .wave {
position: absolute;
right: 0;
background-size: 160px 50px;
background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='60' height='10' fill='%23fff' viewBox='0 0 60 10' version='1.1'><defs><filter id='shadow' x='-10' y='-10' width='15' height='15'><feOffset result='offOut' in='SourceAlpha' dx='0' dy='-1'></feOffset><feGaussianBlur result='blurOut' in='offOut' stdDeviation='1'></feGaussianBlur><feBlend in='SourceGraphic' in2='blurOut' mode='normal'></feBlend> </filter></defs><path d='M0,5 C25,0 35,10 60,5 v5 H0' filter='url(%23shadow)'/></svg>");
height: 50px;
left: -160px;

}
.wave-container .wave.w1 {
bottom: 0;
}
.wave-container .wave.w2 {
top: 0;
}
<div class="wave-container">
<div class="wave w1"></div>
<div class="wave w2"></div>
</div>

最佳答案

您看到的不连续性是阴影在到达形状边缘时逐渐消退。

不要恰好在 SVG 的边缘结束您的路径,而是尝试将形状延伸到离左右边缘更远的地方。在下面的示例中,我用五个单位的线段将形状的每一侧都扩展得更宽。

.wave-container {
position: absolute;
width: 100%;
height: 100%;
color: #fff;
padding: 8px;
padding-bottom: 50px;
display: flex;
flex-direction: column;
justify-content: center;
text-align: center;
overflow: hidden;
background-color: #ccc;
}
.wave-container .wave {
position: absolute;
right: 0;
background-size: 160px 50px;
background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='60' height='10' fill='%23fff' viewBox='0 0 60 10' version='1.1'><defs><filter id='shadow' x='-10' y='-10' width='15' height='15'><feOffset result='offOut' in='SourceAlpha' dx='0' dy='-1'></feOffset><feGaussianBlur result='blurOut' in='offOut' stdDeviation='1'></feGaussianBlur><feBlend in='SourceGraphic' in2='blurOut' mode='normal'></feBlend> </filter></defs><path d='M-5,5 L0,5 C25,0 35,10 60,5 H 65 v5 H-5' filter='url(%23shadow)'/></svg>");
height: 50px;
left: -160px;

}
.wave-container .wave.w1 {
bottom: 0;
}
.wave-container .wave.w2 {
top: 0;
}
<div class="wave-container">
<div class="wave w1"></div>
<div class="wave w2"></div>
</div>

关于css - svg 过滤器阴影路径修复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53448154/

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