svg+css实现播放按钮鼠标悬浮扇形进度延迟动画显示文本效果代码
代码语言:html
所属分类:悬停
代码描述:svg+css实现播放按钮鼠标悬浮扇形进度延迟动画显示文本效果代码
代码标签: svg css 播放 按钮 鼠标 悬浮 扇形 进度 延迟 动画 显示 文本
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/open-props.easings.css"> <style> /* @property used because the effect transitions these within a gradient */ @property --btn-conic-hint { syntax: "<percentage>"; inherits: false; initial-value: 0%; /* will transition 0%-100% */ } @property --btn-effect-opacity { syntax: "<percentage>"; inherits: false; initial-value: 0%; /* will transition 0%-5% */ } button { --anchor-name: ; /* unique per instance */ anchor-name: var(--anchor-name); /* used so the conic only animates the hint on hover-in */ --btn-conic-hint-duration: 0s; --btn-conic-hint-delay: .5s; /* adaptive semi-transparent hover highlight */ --highlight-color: light-dark( hsl(0 0% 0% / var(--btn-effect-opacity)), hsl(0 0% 100% / var(--btn-effect-opacity)) ); /* 2 layers: - an opacity fading solid color layer - the conic gradient that does the radar effect */ background: conic-gradient(var(--highlight-color) 0 0), conic-gradient( var(--highlight-color), var(--btn-conic-hint), transparent 0 ); @media (prefers-reduced-motion: no-preference) { /* transitions the @property props */ transition: outline-offset 145ms var(--ease-4), --btn-conic-hint var(--btn-conic-hint-duration) var(--ease-in-out-4) var(--btn-conic-hint-delay), --btn-effect-opacity .7s ease-out; & > svg { transition: scale 1s var(--ease-spring-4); } } &:is(:hover, :focus-visible) { /* animate the conic to completion */ --btn-conic-hint: 100%; /* give the conic completion duration */ --btn-conic-hint-duration: 1s; /* give highlight some opacity */ --btn-effect-opacity: 5%; &::before { opacity: 1; transform: none; transition-delay: calc(var(--btn-conic-hint-duration) + var(--btn-conic-hint-delay)); } } @media (prefers-color-scheme: dark) { &:is(:hover, :focus-visible) { /* dark/dim screens need more highlight opacity */ --btn-effect-opacity: 15%; } } &am.........完整代码请登录后点击上方下载按钮下载查看
网友评论0