首页前端开发CSScss3 模仿树叶被风吹效果

css3 模仿树叶被风吹效果

时间2023-12-04 03:36:03发布访客分类CSS浏览907
导读:CSS3模仿树叶被风吹效果.tree {height: 500px;background-color: #8BC34A;position: relative;overflow: hidden;}.leaf {position: absolu...

CSS3模仿树叶被风吹效果

.tree {
    height: 500px;
    background-color: #8BC34A;
    position: relative;
    overflow: hidden;
}
.leaf {
    position: absolute;
    width: 80px;
    height: 80px;
    background-color: #689F38;
    border-radius: 50%;
    z-index: 1;
    animation-name: leaf-sway;
    animation-duration: 3s;
    animation-timing-function: ease-in-out;
    animation-iteration-count: infinite;
}
.leaf:nth-child(1) {
    top: 200px;
    left: 50px;
    animation-delay: 0s;
}
.leaf:nth-child(2) {
    top: 150px;
    left: 200px;
    animation-delay: 1s;
}
.leaf:nth-child(3) {
    top: 250px;
    left: 350px;
    animation-delay: 2s;
}
.leaf:nth-child(4) {
    top: 450px;
    left: 100px;
    animation-delay: 3s;
}
.leaf:nth-child(5) {
    top: 350px;
    left: 300px;
    animation-delay: 4s;
}
@keyframes leaf-sway {
0% {
    transform: rotate(0deg);
}
50% {
    transform: rotate(20deg);
}
100% {
    transform: rotate(0deg);
}
}
    

以上是CSS3模仿树叶被风吹效果的代码,通过设置animation属性,让叶子向左右摇动,显示出被风吹动的效果。

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


若转载请注明出处: css3 模仿树叶被风吹效果
本文地址: https://pptw.com/jishu/567099.html
css处理元字符串 css增加每行内容数量

游客 回复需填写必要信息