css实现玻璃形态图标按钮悬浮动画效果代码
代码语言:html
所属分类:悬停
代码描述:css实现玻璃形态图标按钮悬浮动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> body { position: relative; display: flex; justify-content: center; align-items: center; width: 100%; height: 100vh; min-height: 400px; background-color: #fbfbfb; } body .block-container { position: relative; width: 120px; height: 120px; margin: 32px; transition: 250ms; perspective: 500px; } body .block-container .btn-back { position: absolute; inset: 0; z-index: -1; width: inherit; height: inherit; border-radius: 32px; transition: 250ms; transform-style: preserve-3d; transform-origin: bottom right; transform: rotateZ(15deg); will-change: transform; box-shadow: 16px 0 40px #e4e4e4; } body .block-container .btn-back-1 { background: linear-gradient(135deg, #4682eb -20%, #01beff 120%); } body .block-container .btn-back-2 { background: linear-gradient(135deg, #5c46eb -20%, #013fff 120%); } body .block-container .btn-back-3 { background: linear-gradient(135deg, #ebe046 -20%, #ffac01 120%); } body .block-container .btn-front { position: absolute; inset: 0; z-index: 1; width: inherit; height: inherit; border-radius: 32px; background-color: #ffffff33; -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); transition: 250ms; transform-style: preserve-3d; transform-origin: top left; overflow: hidden; } body .block-container .btn-front svg.frame { width: inherit; height: inherit; } body .block-container .btn-front svg.frame rect { width: inherit; height: inherit; fill: none; stroke-width: 4; } body .block-container .btn-front svg.icon { position: absolute; inset: 50% 0 0 50%; transform: translate(-50%, -50%); } body .block-container:hover > .btn-back { transform: translateZ(20px) rotateZ(15deg) rotateX(-20deg) rotateY(-20deg); } body .block-container:hover > .btn-front { transform: translateZ(80px) translateY(-5px) rotateX(15deg) rotateY(15deg); } @media (max-width: 600px) { body { flex-direction: column; } } </style> </head> <body > <div class="block-container"> <div class="btn-back btn-back-1"></div> <div class="btn-front"> <svg class="frame"> <rect rx="32" stroke="url(#gradient-half)" /> </svg> <svg xmlns="http://www.w3.org/2000/svg" class="icon" width="48" height="48" viewBox="0 0 24 24" fill="none"> <path d="M12.3999 17.4999C11.8999 17.2999 11.2999 17.3999 11.0999 17.8999L9.29989 21.4999C8.99989 21.9999 9.19989 22.5999 9.69989 22.8999C9.79989 22.9999 9.99989 22.9999 10.1999 22.9999C10.5999 22.9999 10.8999 22.7999 11.0999 22.4999L12.8999 18.8999C13.0999 18.2999 12.8999 17.6999 12.3999 17.4999Z" fill="url(#gradient-full)" /> <path d="M17 17.4999C16.5 17.2999 15.9 17.3999 15.7 17.8999L13.9 21.4999C13.7 21.9999 13.8 22.5999 14.3 22.7999C14.4 22.8999 14.6 22.8999 14.8 22.8999C15.2 22.8999 15.5 22.6999 15.7 22.3999L17.5 18.7999C17.7 18.2999 17.5 17.6999 17 17.4999Z" fill="url(#gradient-full)" /> <path d="M7.89994 17.4999C7.39994 17.2999 6.79994 17.3999 6.59994 17.8999L4.79994 21.4999C4.59994 21.9999 4.69994 22.5999 5.19994 22.7999C5.2.........完整代码请登录后点击上方下载按钮下载查看
网友评论0