纯css实现稻草人跳动动画效果
代码语言:html
所属分类:动画
代码描述:纯css实现稻草人跳动动画效果
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style> body { background-color: #c8dffd; display: flex; flex-direction: column; justify-content: center; align-items: center; height: 100vh; } .turnip { position: relative; animation: hop 0.2s ease-in alternate infinite; } .turnip__hat { position: relative; border-top-left-radius: 5px; border-top-right-radius: 5px; border-top: 45px solid #515559; border-left: 1px solid transparent; border-right: 1px solid transparent; width: 55px; margin: 0 auto -3px; z-index: 1; } .turnip__hat:before { content: ""; position: absolute; top: -87px; right: -23px; background-color: #515559; width: 9px; height: 55px; border-radius: 100%; transform: rotate(50deg); } .turnip__hat:after { content: ""; position: absolute; top: 12px; left: -15px; background-color: #515559; width: 85px; height: 10px; border-radius: 40% 40% 70% 70%; } .turnip__ribbon { width: 55px; height: 12px; background-color: #d996b5; margin: 0 auto; } .turnip__head { position: relative; background-color: #f2f2f2; width: 70px; height: 55px; margin: 0 auto; border-radius: 50%; display: flex; justify-content: space-around; flex-flow: row wrap; } .turnip__eye { width: 6px; height: 6px; background-color: #000; border-radius: 50%; margin: 20px 5px 0; } .turnip__mouth { width: 45px; height: 15px; background-color: #fff; border-radius: 50%; } .turnip__pipe { position: absolute; top: 40px; left: 60px; width: 40px; height: 2px; background-color: #8c8070; } .turnip__pipe:before { content: ""; position: absolute; width: 9px; height: 17px; background-color: #8c8070; border-radius: 3px; left: 40px; top: -7px; } .turnip__body { position: relative; width: 250px; z-index: 1; } .turnip__coat { position: absolute; top: 15px; left: 0; right: 0; margin-left: auto; margin-right: auto; border-top: 100px solid #515559; border-left: 5px solid transparent; border-right: 5px solid transparent; width: 75px; } .turnip__bow { position: absolute; top: 20px; left: 0; right: 0; margin-left: auto; margin-right: auto; background-color: #3a485d; width: 10px; height: 10px; z-index: 3; border-radius: 2px; } .turnip__bow:before { content: ""; position: absolute; top: -10px; left: -25px; width: 0; height: 10px; border-top: 10px solid transparent; border-left: 25px solid #5a6b8c; border-bottom: 10px solid transparent; border-radius: 8px; } .turnip__bow:after { content: ""; position: absolute; top: -10px; right: -25px; width: 0; height: 10px; border-top: 10px solid transparent; border-right: 25px solid #5a6b8c; border-bottom: 10px solid transparent; border-radius: 8px; } .turnip__shirt { position: absolute; top: 8px; left: 0; right: 0; margin-left: auto; margin-right: auto; width: 30px; height: 35px; z-index: 2; } .turnip__shirt:before { content: ""; position: absolute; top: 0; left: -5px; height: 100%; width: 70%; background-color: #dbb2c2; transform: skew(1deg, 35deg); border-bottom-left-radius: 90px; border-top-left-radius: 15px; border-bottom-right-radius: 15px; border-top-right-radius: 10px; } .turnip__shirt:after { content: ""; position: absolute; top: 0; right: -5px; height: 100%; width: 70%; background-color: #dbb2c2; transform: skew(-1deg, -35deg); border-top-right-radius: 15px; border-bottom-right-radius: 90px; border-bottom-left-radius: 15px; border-top-left-radius: 10px; } .turnip__waistcoat { position: absolute; top: 15px; left: -1px; right: 0; margin-left: auto; margin-right: auto; width: 35px; height: 50px; } .turnip__waistcoat:before { content: ""; position: absolute; top: 0; left: -4px; height: 100%; width: 65%; background-color: #83a6bc; transform: skew(0deg, 40deg); border-bottom-left-radius: 90px; border-top-left-radius: 90px; border-bottom-right-radius: 15px; } .turnip__waistcoat:after { content: ""; position: absolute; top: 0; right: -5px; height: 100%; width: 65%; background-color: #83a6bc; transform: skew(0deg, -40deg); border-top-right-radius: 90px; border-bottom-right-radius: 90px; border-bottom-left-radius: 15px; } .turnip__coattails { position: absolute; top: 105px; left: 0; right: 0; margin-left: auto; margin-right: auto; width: 75px; height: 120px; z-index: 1; } .turnip__coattails:before { content: ""; position: absolute; top: 0; left: 8px; height: 100%; width: 60%; background-color: #515559; transform-origin: top; transform: skew(-25deg, 30deg) rotate(0deg); border-bottom-left-radius: 50px; border-bottom-right-radius: 5px; animation: coattails-left 0.2s ease-in alternate infinite; } .turnip__coat.........完整代码请登录后点击上方下载按钮下载查看
网友评论0