svg+css实现按钮鼠标悬浮植物树叶生长动画效果代码
代码语言:html
所属分类:悬停
代码描述:svg+css实现按钮鼠标悬浮植物树叶生长动画效果代码
代码标签: svg css 按钮 鼠标 悬浮 植物 树叶 生长 动画
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum=1.0,minimum=1.0,user-scalable=0" /> <style> button { position: relative; padding: 13px 35px; background: #f5ddb7; font-size: 17px; font-weight: 900; color: #181818; border: none; border-radius: 8px; box-shadow: 2px 2px 5px #18181869, inset 2px 2px 10px #ffffffb0; transition: all .3s ease-in-out; } .icon-1 { position: absolute; top: 10%; left: 50%; transform: translate(-50%, 0); width: 0px; height: auto; transition: all .5s ease-in-out; z-index: -1; } .icon-2 { position: absolute; top: 10%; left: 50%; transform: translate(-50%, 0); width: 0px; height: auto; transition: all .5s ease-in-out; z-index: -2; } .icon-3 { position: absolute; top: 10%; left: 50%; transform: translate(-50%, 0); width: 0px; height: auto; transition: all .5s ease-in-out; z-index: -2; } .icon-4 { position: absolute; top: 10%; left: 50%; transform: translate(-50%, 0); width: 0px; height: auto; transition: all .5s ease-in-out; z-index: -2; } .icon-5 { position: absolute; top: 10%; left: 50%; transform: translate(-50%, 0); width: 0px; height: auto; transition: all .5s ease-in-out; z-index: -2; } button:hover { padding: 13px 25px; border-radius: 8px 8px 24px 24px; } button:hover .icon-1 { top: -250%; left: 50%; transform: translate(-50%, 0); width: 50px; height: auto; animation: inIcon1 1s ease .45s forwards; } @keyframes inIcon1 { 0% { transform-origin: 0 100%; transform: translate(-50%, 0) rotate(0deg); } 25% { transform-origin: 0 100%; transform: translate(-50%, 0) rotate(5deg); } 50% { transform-origin: 0 100%; transform: translate(-50%, 0) rotate(1deg); } 65% { transform-origin: 0 100%; transform: translate(-50%, 0) rotate(3deg); } 100% { transform-origin: 0 100%; transform: translate(-50%, 0) rotate(0deg); } } button:hover .icon-2 { position: absolute; top: -200%; left: 90%; transform: translate(-50%, 0); width: 75px; height: auto; animation: inIcon2 1s ease .45s forwards; } @keyframes inIcon2 { 0% { transform-origin: 0 100%; transform: translate(-50%, 0) rotate(0deg); } 35% { transform-origin: 0 100%; transform: translate(-50%, 0) rotate(10deg); } 50% { transform-origin: 0 100%; transform: translate(-50%, 0) rotate(4deg); } 80% { transform-origin: 0 100%; transform: translate(-50%, 0) rotate(5deg); } 100% { transform-origin: 0 100%; transform: translate(-50%, 0) rotate(0deg); } } button:hover .icon-3 { position: absolute; top: -130%; left: 20%; transform: translate(-50%, 0); width: 60px; height: auto; animation: inIcon3 1s ease .45s forwards; } @keyframes inIcon3 { 0% { transform-origin: 0 100%; transform: translate(-50%, 0) rotate(0deg); } 35% { transform-origin: 0 100%; transform: translate(-50%, 0) rotate(-2deg); } 100% { transform-origin: 0 100%; transform: translate(-50%, 0) rotate(0deg); } } button:hover .icon-4 { position: absolute; top: -300%; left: 10%; transform: translate(-50%, 0); width: 85px; height: auto; animation: inIcon4 1s ease .45s forwards; } @keyframes inIcon4 { 0% { transform-origin: 0 100%; transform: translate(-50%, 0) rotate(0deg); } 40% { transform-origin: 0 100%; transform: translate(-50%, 0) rotate(-3deg); } 100% { transform-origin: 0 100%; transform: translate(-50%, 0) rotate(0deg); } } button:hover .icon-5 { position: absolute; top: -350%; left: 90%; transform: translate(-50%, 0); width: 85px; height: auto; animation: inIcon5 1s ease .45s forwards; } @keyframes inIcon5 { 0% { transform-origin: 0 100%; transform: translate(-50%, 0) rotate(0deg); } 35% { transform-origin: 0 100%; transform: translate(-50%, 0) rotate(-3deg); } 100% { transform-origin: 0 100%; transform: translate(-50%, 0) rotate(0deg); } } .fil-leaf-1 { fill: #7B9B3A } .fil-leaf-2 { fill: #556729; fill-rule: nonzero } .fil-leaf-3 { fill: #556729 } .fil-leaf-4 { fill: #3C4819 } .fil-leaf-5 { fill: #3C4819 } </style> </head> <body> <button style="margin:200px;">Plant based <div class="icon-1"> <svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" version="1.1" style="shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd" viewBox="0 0 208.52 511.88" xmlns:xlink="http://www.w3.org/1999/xlink"><defs></defs><g id="Layer_x0020_1"><metadata id="CorelCorpID_0Corel-Layer"></metadata><path class="fil-leaf-1" d="M121.86 141.25c16.73,2.91 65.77,9.16 77.74,-14.94 14.49,-29.19 12.6,-56.91 -15.12,-69.09 -11.3,-4.96 -22.28,-7.7 -32.28,-9.66 -24.58,24.72 -41.22,75.51 -43.83,83.82 4.31,3.56 8.81,6.86 13.49,9.87zm-17.26 41.05c2.87,7.92 8.26,29.59 7.63,79.7 -0.16,12.74 -0.48,25.41 -0.81,38.43 -1.4,55.59 -2.96,117.52 7.12,210.69l-7.09 0.75c-10.12,-93.56 -8.56,-155.77 -7.15,-211.61 0.33,-13.06 0.65,-25.77 0.81,-38.35 0.53,-42.42 -3.06,-63.29 -5.69,-72.77 -7.55,8.48 -18.48,15.07 -34.33,16.54 -26.77,2.47 -43.19,-16.99 -52.84,-36.58 16.49,-8.49 65.65,-32.22 98.27,-31.47 1.86,1.42 3.76,2.8 5.69,4.13 -0.15,5.56 -1.43,24.61 -11.62,40.53zm-41.18 -148.65c-0.32,0.84 1.68,9.87 -6.19,10.71 -7.87,0.84 -3.26,-5.14 -6.82,-7.98 -3.57,-2.84 -9.97,-14.59 1.99,-15.96 11.97,-1.37 11.02,13.23 11.02,13.23zm124.63 55.54c0,0 -3.89,14.8 -10.18,18.69 -6.3,3.88 -22.78,7.24 -28.87,0.11 -6.09,-7.14 -1.57,-31.71 17.64,-30.45 19.21,1.26 22.68,8.4 21.42,11.65zm-101.53 67.51c0,0 5.88,5.56 5.46,9.87 -0.42,4.3 -5.78,19.21 -14.07,20.05 -8.29,0.84 -24.15,-6.82 -21.84,-17.53 2.31,-10.71 10.5,-11.34 12.6,-10.6 2.1,0.74 3.36,2.1 17.85,-1.78zm61.49 -109.94c-12.74,-2.33 -23.63,-3.69 -31.15,-7.4 0,0 -2.41,15.22 -4.51,19.74 -2.1,4.51 -6.3,17.32 -14.8,21.1 -8.5,3.78 -9.87,-28.14 4.62,-45.15 0,0 -10.13,-4.4 -22.34,-9.92 -11.47,31.21 -7.3,64.58 -7.28,64.68l-0.48 0.06c9.73,14.77 20.76,28.04 33.37,39.01 3.68,-11.43 19.48,-57.46 42.58,-82.12zm-71.44 -23.1c-16.59,-7.55 -35.59,-16.58 -38.25,-19.47 -1.97,-2.14 -4.87,-3.72 -7.63,-4.2 9.11,27.4 20.23,54.59 34.36,78.62 1.13,1.92 2.28,3.82 3.45,5.7 -0.66,-11.21 -0.85,-36.........完整代码请登录后点击上方下载按钮下载查看
网友评论0