div+css实现鱼塘水下鱼儿游动2d动画效果代码
代码语言:html
所属分类:动画
代码描述:div+css实现鱼塘水下鱼儿游动2d动画效果代码
代码标签: div css 鱼塘 水下 鱼儿 游动 2d 动画
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> body { height: 100vh; width: 100vw; display: flex; justify-content: center; align-items: center; } .tank { display: flex; align-items: flex-end; border: 10px solid darkblue; width: 50vw; height: 50vh; } .water { position: relative; height: 80%; width: 100%; overflow: hidden; max-width: 100%; background-color: aqua; } .fish { position: absolute; width: 3rem; height: 3rem; background: red linear-gradient(red, blue); clip-path: polygon(0% 50%, 80% 0%, 100% 20%, 100% 80%, 80% 100%); z-index: 1; } .fish_wrapper:nth-child(1) .fish { background: black linear-gradient(90deg, white, black, white, black); } .fish_wrapper:nth-child(1):after { background: black linear-gradient(black, goldenrod); } .fish_wrapper:nth-child(2) .fish { background: black linear-gradient(90deg, white, black, goldenrod, black); } .fish_wrapper:nth-child(2):after { background: black linear-gradient(90deg, white, white, goldenrod); } .fish_wrapper:nth-child(3) .fish { background-color: hsla(0, 100%, 50%, 1); background-image: radial-gradient( at 40% 20%, hsla(28, 100%, 74%, 1) 0px, transparent 50% ), radial-gradient(at 80% 0%, hsla(189, 100%, 56%, 1) 0px, transparent 50%), radial-gradient(at 0% 50%, hsla(355, 100%, 93%, 1) 0px, transparent 50%), radial-gradient(at 80% 50%, hsla(340, 100%, 76%, 1) 0px, transparent 50%), radial-gradient(at 0% 100%, hsla(22, 100%, 77%, 1) 0px, transparent 50%), radial-gradient(at 80% 100%, hsla(242, 100%, 70%, 1) 0px, transparent 50%), radial-gradient(at 0% 0%, hsla(343, 100%, 76%, 1) 0px, transparent 50%); } .fish_wrapper:nth-child(3):after { background-color: hsla(0, 100%, 50%, 1); background-image: radial-gradient( at 40% 20%, hsla(28, 100%, 74%, 1) 0px, transparent 50% ), radial-gradient(at 80% 0%, hsla(189, 100%, 56%, 1) 0px, transparent 50%), radial-gradient(at 0% 50%, hsla(355, 100%, 93%, 1) 0px, transparent 50%), radial-gradient(at 80% 50%, hsla(340, 100%, 76%, 1) 0px, transparent 50%), radial-gradient(at 0% 100%, hsla(22, 100%, 77%, 1) 0px, transparent 50%), radial-gradient(at 80% 100%, hsla(242, 100%, 70%, 1) 0px, transparent 50%), radial-gradient(at 0% 0%, hsla(343, 100%, 76%, 1) 0px, transparent 50%); } .fish_wrapper:nth-child(4) .fish { background-color: #99aaff; background-image: radial-gradient( at 28% 16%, hsla(17, 78%, 72%, 1) 0px, transparent 50% ), radial-gradient(at 94% 83%, hsla(130, 78%, 64%, 1) 0px, transparent 50%), radial-gradient(at 38% 31%, hsla(67, 78%, 69%, 1) 0px, transparent 50%), radial-gradient(at 58% 23%, hsla(11, 99%, 67%, 1) 0px, transparent 50%), radial-gradient(at 56% 17%, hsla(1, 91%, 74%, 1) 0px, transparent 50%), radial-gradient(at 86% 84%, hsla(78, 67%, 69%, 1) 0px, transparent 50%), radial-gradient(at 48% 4%, hsla(91, 72%, 67%, 1) 0px, transparent 50%); } .fish_wrapper:nth-child(4):after { background: black linear-gradient(90deg, white, white, greenyellow); } .fish_wrapper:nth-child(5) .fish { background: black linear-gradient(90deg, slateblue, white, slateblue, black); } .fish_wrapper:nth-child(5):after { background: black linear-gradient(90deg, white, white, slateblue); } .fish_wrapper { position: absolute; } .fish_wrapper::before { content: ""; position: absolute; width: 0.5rem; height: 0.5rem; border-radius: 50%; background-color: white; transform: translatey(1.25rem) translatex(-0.5rem); animation: bubble 3s ease-in-out 0s infinite forwards; } .fish_wrapper::after { content: ""; position: absolute; width: 2rem; height: 2rem; top: 0.5rem; right: -4rem; background: red linear-gradient(red, blue); clip-path: polygon(0% 50%, 100% 0%, 100% 100%); z-index: 0; animation: tail 1s ease-in-out 0s infinite forwards; } .fish_wrapper:nth.........完整代码请登录后点击上方下载按钮下载查看
网友评论0