gpt4 book ai didi

css - 如何用CSS反转波浪SVG?

转载 作者:太空宇宙 更新时间:2023-11-03 22:17:06 25 4
gpt4 key购买 nike

我创建了一个带有背景图像的英雄横幅和一个 SVG,它使波浪效果覆盖在图像上。

但我不知道如何反转这个波,我的意思是改变谷的两侧和波峰。

<section class="herobanner"></section>

.herobanner {
height:100vh;
background:
url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 54 54" width="2000" ><path d="M0 48 C30 60 38 40 64 48 L64 64 L0 64 Z" fill="white" stroke="rgba(255,255,255,1)" stroke-width="2"/></svg>') bottom,
url('../images/bg/herobanner3.jpg') center/cover;

}

我尝试更改 svg 路径中​​的一些数字,但没有成功。

最佳答案

为了反转波浪,您需要对其进行缩放。例如你的 svg 是这样的:

svg{border:1px solid;transform:scale(-1,1)}
<svg viewBox="0 45 64 19" ><path d="M0 48 C30 60 38 40 64 48 L64 64 L0 64 Z"  stroke="red" /></svg>

或者,您可以使用表示属性代替 css:

<svg viewBox="0 45 64 20" ><path transform="scale(-1,1) translate(-64,0)" d="M0 48 C30 60 38 40 64 48 L64 64 L0 64 Z"  stroke="red" /></svg>

您可以使用此 SVG 元素作为背景:

.herobanner {
border:1px solid;
height:100vh;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 45 64 20'%3E%3Cpath transform='scale(-1,1) translate(-64,0)' d='M0 48 C30 60 38 40 64 48 L64 64 L0 64 Z' stroke='red' /%3E%3C/svg%3E");
background-repeat:no-repeat;
}
<section class="herobanner"></section>

或者您可以使用 CSS 转换 .herobanner:

.herobanner {
border:1px solid;
height:100vh;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 45 64 20'%3E%3Cpath d='M0 48 C30 60 38 40 64 48 L64 64 L0 64 Z' stroke='red' /%3E%3C/svg%3E");
background-repeat:no-repeat;
transform:scale(-1,1)
}
<section class="herobanner"></section>

关于css - 如何用CSS反转波浪SVG?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56159782/

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