gsap+svg实现可爱零正数负数拖动效果代码
代码语言:html
所属分类:拖放
代码描述:gsap+svg实现可爱零正数负数拖动效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <link rel='stylesheet' href='https://fonts.googleapis.com/css2?family=Quicksand:wght@700&display=swap'> <style> body { height: 100vh; margin: 0; padding: 0; background: #bdc5ff; } .grid { position: relative; display: grid; width: 100%; height: 100%; overflow: hidden; place-items: center; } .runner { position: absolute; display: grid; grid-template-columns: repeat(3, 1fr); width: 300vw; background: linear-gradient(to bottom, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0)); } .number { position: relative; display: inline-flex; justify-content: center; width: 100vw; height: 100vh; } input[type=range] { -webkit-appearance: none; appearance: none; background: transparent; cursor: pointer; width: 200px; position: fixed; bottom: 2rem; left: calc(50% - 100px); } input[type=range]::-webkit-slider-runnable-track { background: #fcfcfc; height: 1rem; border-radius: 0.25rem; border: 3px solid black; } input[type=range]::-moz-range-track { background: #fcfcfc; height: 1rem; border-radius: 0.25rem; border: 3px solid black; } input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; margin-top: -0.75rem; background-color: #ffd433; width: 2rem; height: 2rem; border-radius: 6px; border: 3px solid black; box-shadow: 2px 2px 0 0 black; } input[type=range]::-moz-range-thumb { margin-top: -0.75rem; background-color: #ffd433; width: 2rem; height: 2rem; border-radius: 6px; border: 3px solid black; box-shadow: 2px 2px 0 0 black; } svg { overflow: visible; } .shadow { fill: rgba(0, 0, 0, 0.1); } .leg, .foot, .mouth, .body, .eyebrows { fill: none; stroke: #000; stroke-linecap: round; stroke-width: 6px; } .foot, .mouth { stroke-width: 8px; } .neutral { fill: #99a1ff; } .neutral.dark { fill: #808aff; } .neutral.shadow { fill: #6672ff; fill-opacity: 0.2; } .negative { fill: #ff4d6f; } .negative.dark { fill: #ff345a; } .negative.shadow { fill: #ff1a46; fill-opacity: 0.2; } .positive { fill: #2fda98; } .positive.dark { fill: #24cb8b; } .positive.shadow { fill: #20b67c; fill-opacity: 0.2; } </style> </head> <body > <div class="grid"> <div class="runner"> <!-- Negative --> <div class="number"> <svg id="Negative" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 400 400"> <defs> <clipPath id="neg-eye-clip"> <path d="M216.15,172c0,8.28-5.6,15-12.5,15-6.9,0-12.5-6.72-12.5-15,0-8.28,5.6-15,12.5-15s12.5,6.72,12.5,15Z" style="fill: none;"/> </clipPath> <g id="neg-eye" clip-path="url(#neg-eye-clip)"> <path d="M216.5,172c0,8.28-5.6,15-12.5,15-6.9,0-12.5-6.72-12.5-15,0-8.28,5.6-15,12.5-15s12.5,6.72,12.5,15Z" style="fill: #fff;"/> <circle cx="204" cy="149" r="15" class="negative eyelids" /> <ellipse cx="204" cy="174" rx="6" ry="6.5" class="pupils" /> </g> </defs> <ellipse class="negative shadow" cx="198.18" cy="343.08" rx="83.88" ry="11.71"/> <g id="left-leg"> <path class="leg" d="M210.13,286.96c-7.94,13.61-6.8,30.45-5.43,46.14"/> <path class="foot" d="M204.46,334.01c-5.37,.21-10.67,2.13-14.92,5.43"/> </g> <g id="right-leg"> <path class="leg" d="M230.03,286.96c7.94,13.61,6.8,30.45,5.43,46.14"/> <path class="foot" d="M235.7,334.01c5.37,.21,10.67,2.13,14.92,5.43"/> </g> <g id="minus"> <path class="body negative" d="M96.61,194.7h56.32c4.75,0,8.61,3.86,8.61,8.61v7.18c0,3.44-2.79,6.23-6.23,6.23h-57.84c-4.75,0-8.61-3.86-8.61-8.61v-5.66c0-4.28,3.47-7.76,7.76-7.76Z"/> <path class="negative dark" d="M153.76,209.77h-54.7c-4.5,0-8.15-3.34-8.15-7.47v5.01c0,4.58,2.36,7.47,8.15,7.47h55.71c3.17,0,4.89-1.84,4.89-4.4v-6.01c0,2.98-2.64,5.4-5.9,5.4Z" /> </g> <g id="body"> <path class="body negative" d="M151.94,81.15l41.88-11.27c3.48-.69,19.99-1.03,23.53-1.03h16.99c11.38,0,20.65,9.13,20.83,20.51l3.12,195.78c.19,11.74-9.28,21.36-21.02,21.36h-34.94c-11.78,0-21.26-9.68-21.02-21.46l3.18-153.2c.15-7.23-5.68-13.17-12.91-13.16l-16.42,3.03c-9.12,.02-16.52-7.37-16.52-16.49v-7.89c0-7.87,5.57-14.65,13.29-16.17Z"/> <g class="negative dark"> <path d="M184.73,123.55c.15-7.23-5.68-13.17-12.91-13.16l-16.42,3.03c-9.06,.02-16.41-7.27-16.51-16.31,0,.07,0,.14,0,.21v7.89c0,9.12,7.4,16.51,16.52,16.49l16.42-3.03c6.55-.01,11.93,4.86,12.78,11.15l.13-6.26Z" /> <path d="M237.52,298.21h-34.94c-10.88,0-19.8-8.26-20.9-18.81l-.12,5.62c-.24,11.78,9.24,21.46,21.02,21.46h34.94c11.74,0,21.21-9.62,21.02-21.36l-.09-5.96c-.99,10.66-9.96,19.05-20.92,19.05Z"/> </g> <path class="mouth" id="mouth" d="M198.05,272.45c8.02-6.72,17.43-11.76,27.46-14.72,5.47-1.61,11.23-2.62,16.89-1.83" /> <use xlink:href="#neg-eye" /> <use xlink:href="#neg-eye" x="32"/> <path class="body" d="M151.94,81.15l41.88-11.27c3.48-.69,19.99-1.03,23.53-1.03h16.99c11.38,0,20.65,9.13,20.83,20.51l3.12,195.78c.19,11.74-9.28,21.36-21.02,21.36h-34.94c-11.78,0-21.26-9.68-21.02-21.46l3.18-153.2c.15-7.23-5.68-13.17-12.91-13.16l-16.42,3.03c-9.12,.02-16.52-7.37-16.52-16.49v-7.89c0-7.87,5.57-14.65,13.29-16.17Z" /> </g> </svg> </g> </div> <!-- Neutral --> <div class="number"> <svg id="Neutral" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 400"> <ellipse class="neutral shadow" cx="195.4" cy="346.87" rx="91.75" ry="7.86"/> <!-- feet --> <path class="leg" d="M149.84,292.48c-7.94,13.61-6.8,30.45-5.43,46.14"/> <path class="foot" d="M144.17,339.53c-5.37,.21-10.67,2.13-14.92,5.43"/> <path class="leg" d="M246.84,292.48c7.94,13.61,6.8,30.45,5.43,46.14"/> <path class="foot" d="M252.52,339.53c5.37,.21,10.67,2.13,14.92,5.43"/> <!-- body --> <path class="body neutral" d="M200.02,56.31c-152.13-5.18-136.36,258.61,.78,250,135.26,7.88,154.98-257.17-.78-250Zm2.68,171.82c-43.89,1.4-41.21-74.46-.23-73.74,41.75-.89,42.64,74.47,.23,73.74Z" /> <path class="neutral dark" d="M200.54,293.07c-51.76,0-94.95-41.8-105-97.39,5.42,66.93,50.25,109.53,104.75,109.53s97.06-40.5,104.26-104.55c-11.67,53.09-53.8,92.41-104,92.41Z"/> <!-- eyes --> <g class="eyes"> <ellipse cx="170" cy="120" rx="16" ry="16" style="fill: #fff;"/> <ellipse class="pupils" cx="170" cy="120" rx="5" ry="6"/> <path class="eyelid-bot" d="M186.56,137.54c.01,8.83-6.89,16.01-15.41,16.02-8.53,.01-15.45-7.14-15.46-15.97l30.88-.05Z" style="fill: #99a1ff;"/> <path class="eyelid-top" d="M186.56,104.76c-.01-8.83-6.94-15.99-15.46-15.97s-15.43,7.18-15.41,16.02l30.88-.05Z" style="fill: #99a1ff;"/> </g> <g class="eyes" transform="translate(60, 0)"> <ellipse cx="170" cy="120" rx="16" ry="16" style="fill: #fff;"/> <ellipse class="pupils" cx="170" cy="120" rx="5" ry="6"/> <path class="eyelid-bot" d="M186.56,137.54c.01,8.83-6.89,16.01-15.41,16.02-8.53,.01-15.45-7.14-15.46-15.97l30.88-.05Z" style="fill: #99a1ff;"/> <path class="eyelid-top" d="M186.56,104.76c-.01-8.83-6.94-15.99-15.46-15.97s-15.43,7.18-15.41,16.02l30.88-.05Z" style="fill: #99a1ff;"/> </g> <!-- Mouth --> <path class="mouth" d="M170,260 h60"></path> </svg> </div> <!-- Positive --> <div class="number"> <svg id="Positive" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 400"> <ellipse class="positive shadow" cx="203.85" cy="346.37" rx="91.75" ry="7.86" /> <g class="legs" id="left-leg"> .........完整代码请登录后点击上方下载按钮下载查看
网友评论0