css3 hover border 流动效果

css 复制代码
/* Hover 边线流动 */

.hoverDrawLine {
  border: 0 !important;
  position: relative;
  border-radius: 5px;
  --border-color: #60daaa;
}
.hoverDrawLine::before,
.hoverDrawLine::after {
  box-sizing: border-box;
  content: '';
  position: absolute;
  border: 2px solid transparent;
  border-radius: 5px;
  width: 0;
  height: 0;
}
.hoverDrawLine::before {
  top: 0;
  left: 0;
  -webkit-transition: height 0.25s ease-out 0.5s, width 0.25s ease-out 0.75s,
    border-color 0s ease-in-out 1s;
  transition: height 0.25s ease-out 0.5s, width 0.25s ease-out 0.75s,
    border-color 0s ease-in-out 1s;
}
.hoverDrawLine::after {
  bottom: 0;
  right: 0;
  -webkit-transition: height 0.25s ease-out 0s, width 0.25s ease-out 0.25s,
    border-color 0s ease-in-out 0.5s;
  transition: height 0.25s ease-out 0s, width 0.25s ease-out 0.25s,
    border-color 0s ease-in-out 0.5s;
}

.hoverDrawLine:hover::before,
.hoverDrawLine:hover::after {
  width: 100%;
  height: 100%;
}
.hoverDrawLine:hover::before {
  border-top-color: var(--border-color);
  border-right-color: var(--border-color);
  -webkit-transition: width 0.25s ease-out, height 0.25s ease-out 0.25s;
  transition: width 0.25s ease-out, height 0.25s ease-out 0.25s;
}
.hoverDrawLine:hover::after {
  border-bottom-color: var(--border-color);
  border-left-color: var(--border-color);
  -webkit-transition: width 0.25s ease-out 0.5s, height 0.25s ease-out 0.75s;
  transition: width 0.25s ease-out 0.5s, height 0.25s ease-out 0.75s;
}
html 复制代码
<div class="hoverDrawLine"></div>
相关推荐
siger20 小时前
徒手开荒-我用纯Nodejs+pnpm+monorepo改造了一个多vue2的iframe"微前端"项目
前端·node.js·前端工程化
lichenyang45320 小时前
海克斯大乱斗攻略网站 —— 从零开发到云服务器部署全记录
前端
你的代码僚机20 小时前
《别再被 SSO 骗了!前端单点登录原理+避坑指南》
前端
不懂代码的切图仔20 小时前
移动端h5实现横屏在线签名
前端·微信小程序
少卿20 小时前
OpenClaw 的 summarize 技能——开发者的智能摘要利器
前端·后端·程序员
麦秋20 小时前
前端静态页面自动生成(Figma MCP + VS code + Github copilot)
前端·vue.js
不甜情歌20 小时前
JS对象入门|从创建到原理,一篇吃透核心知识点
前端·javascript
DongHao20 小时前
我不想一开始就把 Axios 封装的太完美
前端·http·axios
有一个好名字21 小时前
claude code安装
linux·运维·前端
BIBABULALA21 小时前
Mini Virtual Machine — 可视化虚拟机模拟器(91行)
前端·css·css3