css实现鼠标悬浮彩色渐变边框旋转动画效果代码
代码语言:html
所属分类:悬停
代码描述:css实现鼠标悬浮彩色渐变边框旋转动画效果代码
代码标签: css 鼠标 悬浮 彩色 渐变 边框 旋转 动画
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> .gradient-border::after, .gradient-border::before { bottom: calc(-1 * var(--border-weight)); left: calc(-1 * var(--border-weight)); position: absolute; right: calc(-1 * var(--border-weight)); top: calc(-1 * var(--border-weight)); border-radius: 2rem; content: ""; overflow: hidden; position: absolute; transform: rotate(var(--rotate, 0rad)); transition: transform 0.5s ease-in-out; } .gradient-border { --border-weight: 10px; --border-fallback-color: rgb(60 48 206); --border-gradient: linear-gradient( 130deg, rgb(60 48 206) 0%, rgb(206 46 207) 50%, rgb(255 165 39) 100% ); --border-gradient-alternate: linear-gradient( 130deg, rgb(2 0 36) 0%, rgb(9 9 121) 33%, rgb(0 212 255) 100% ); border-radius: 2rem; position: relative; } .gradient-border::before { background: var(--border-gradient); } .gradient-border::after { -webkit-animation: fade-in-out 4s linear infinite alternate; animation: fade-in-out 4s linear infinite alternate; background: var(--border-gradient-alternate); opacity: 0; z-index: 1; } @media (hover: hover) and (prefers-reduced-motion: no-preference) { .gradient-border:hover::before, .gradient-border:hover::after { --rotate: 3.14159rad; } } @-webkit-keyframes fade-in-out { to { opacity: 1; } } @keyframes fade-in-out { to { opacity: 1; } } :root { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; } .layout { background: linear-gradient(0deg, #ccc, #fff); dis.........完整代码请登录后点击上方下载按钮下载查看
网友评论0