js+css+svg实现三维倾斜可交互按钮点击翻转动画反馈效果代码
代码语言:html
所属分类:其他
代码描述:js+css+svg实现三维倾斜可交互按钮点击翻转动画反馈效果代码
代码标签: js css svg 三维 倾斜 交互 按钮 点击 动画 反馈 翻转
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/open-props.css"> <link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/open-props.normalize.min.css"> <style> body { display: grid; place-items: center; perspective: 800px; overflow: hidden; } body *:not(:empty) { transform-style: preserve-3d; } .scene { position: relative; transform: rotateX(var(--scene-rx, -5deg)) rotateY(var(--scene-ry, -24deg)); transition: transform 0.4s ease-out; } #demo { width: 360px; height: 60px; background: none; transform: rotateX(calc(var(--stateAngle, 0deg) + var(--pa, 0deg))); pointer-events: var(--poinerEvents, all); -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; transition: transform 1s; transition-timing-function: var(--ttf, ease-in-out); } #demo > div { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 0.5em; color: var(--blue-6); background-color: var(--blue-0); border: 1px solid var(--blue-1); text-shadow: 0 1px 0 var(--blue-2); box-shadow: 0 0 10px var(--blue-4) inset; transform: rotateX(var(--rx, 0)) translateZ(calc(30px / tan(60deg))); transition: background-color 0.3s; } #demo > div:nth-child(2) { --rx: 240deg; } #demo > div:nth-child(3) { --rx: 120deg; color: var(--green-6); } #demo:hover > div { background-color: var(--blue-1); } #demo:active { --pa: -30deg; } </style> </head> <body> <div class="scene"> <svg style="display: none"> <symbol id="icon.spinner"> <g> <circle cx="12" cy="12" r="9.5" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round"><animate attributeName="stroke-dasharray" dur="1.5s" calcMode="spline" values="0 150;42 150;42 150;42 150" keyTimes="0;0.475;0.9.........完整代码请登录后点击上方下载按钮下载查看
网友评论0