首页前端开发CSScss3波浪线怎么画

css3波浪线怎么画

时间2023-09-20 00:35:02发布访客分类CSS浏览1036
导读:CSS3波浪线是一种非常流行的网页装饰效果,它通常被用于美化页面中的标题、文本框、图片等元素。下面我们来介绍一下如何使用CSS3实现波浪线效果。.wave {position: relative;height: 80px;width: 10...

CSS3波浪线是一种非常流行的网页装饰效果,它通常被用于美化页面中的标题、文本框、图片等元素。下面我们来介绍一下如何使用CSS3实现波浪线效果。

.wave {
    position: relative;
    height: 80px;
    width: 100%;
    background-color: #ffffff;
}
.wave:before {
    content: '';
    display: block;
    position: absolute;
    border-radius: 100% 50%;
    width: 140%;
    height: 300px;
    top: -200px;
    left: -20%;
    background-color: #f8e1c1;
    transform-origin: center top;
    animation-name: wave;
    animation-duration: 2.5s;
    animation-iteration-count: infinite;
    animation-timing-function: linear;
}
.wave:after {
    content: '';
    display: block;
    position: absolute;
    border-radius: 100% 50%;
    width: 140%;
    height: 250px;
    top: -180px;
    left: -10%;
    background-color: #ffc49a;
    transform-origin: center top;
    animation-name: wave2;
    animation-duration: 2s;
    animation-iteration-count: infinite;
    animation-timing-function: linear;
}
@keyframes wave {
0% {
    transform: rotate(0deg);
}
100% {
    transform: rotate(360deg);
}
}
@keyframes wave2 {
0% {
    transform: rotate(0deg);
}
100% {
    transform: rotate(-360deg);
}
}
    

首先,我们需要创建一个包含波浪线效果的元素,比如一个div。然后,在该元素的:before和:after伪类中分别定义两个波浪线效果。其中,主要使用了border-radius属性来定义圆角效果、transform-origin属性来定义旋转中心点、animation属性来定义动画效果。

通过上述代码,可以实现一个简单的波浪线效果。需要注意的是,如果不需要旋转动画效果,可以将animation相关的属性都去掉。

声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!


若转载请注明出处: css3波浪线怎么画
本文地址: https://pptw.com/jishu/449958.html
mysql字符串拆分为数组 css3沿y轴旋转动画

游客 回复需填写必要信息