鼠标滑过,酷炫来袭:探索网页设计中的按钮动画魔法!

简介: 鼠标滑过,酷炫来袭:探索网页设计中的按钮动画魔法!

先上效果



🌟 网页设计中的按钮不仅是用户交互的桥梁,更是展示创意和技术的平台。酷炫的鼠标经过动画效果能够显著提升按钮的吸引力,激发用户的点击欲望,从而增加用户参与度。本文将介绍几种常用且引人注目的CSS按钮动画效果



完整代码


以下是完整代码:

HTML:

<div class="frame">
  <button class="custom-btn btn-2">btn02</button>
  <button class="custom-btn btn-3"><span>btn03</span></button>
  <button class="custom-btn btn-4"><span>btn04</span></button>
  <button class="custom-btn btn-5"><span>btn05</span></button>
  <button class="custom-btn btn-6"><span>btn06</span></button>
  <button class="custom-btn btn-7"><span>btn07</span></button>
  <button class="custom-btn btn-8"><span>btn08</span></button>
</div>

CSS代码

body {
        background: #e0e5ec;
      }
      h1 {
        position: relative;
        text-align: center;
        color: #353535;
        font-size: 50px;
        font-family: "Cormorant Garamond", serif;
      }
      
      p {
        font-family: 'Lato', sans-serif;
        font-weight: 300;
        text-align: center;
        font-size: 18px;
        color: #676767;
      }
      .frame {
        width: 50%;
        margin: 40px auto;
        text-align: center;
      }
      button {
        margin: 20px;
      }
      .custom-btn {
        width: 130px;
        height: 40px;
        color: #fff;
        border-radius: 5px;
        padding: 10px 25px;
        font-family: 'Lato', sans-serif;
        font-weight: 500;
        background: transparent;
        cursor: pointer;
        transition: all 0.3s ease;
        position: relative;
        display: inline-block;
         box-shadow:inset 2px 2px 2px 0px rgba(125, 111, 111, 0.5),
         7px 7px 20px 0px rgba(0,0,0,.1),
         4px 4px 5px 0px rgba(0,0,0,.1);
        outline: none;
      }
      
      /* 1 */
    
      
      /* 2 */
      .btn-2 {
        background: rgb(96,9,240);
        background: linear-gradient(0deg, rgba(96,9,240,1) 0%, rgba(129,5,240,1) 100%);
        border: none;
        
      }
      .btn-2:before {
        height: 0%;
        width: 2px;
      }
      .btn-2:hover {
        box-shadow: 4px 4px 6px 0 rgba(255,255,255,.5),
                    -4px -4px 6px 0 rgba(116, 125, 136, .5),
          inset -4px -4px 6px 0 rgba(255,255,255,.2),
          inset 4px 4px 6px 0 rgba(0, 0, 0, .4);
      }
      
      
      /* 3 */
      .btn-3 {
        background: rgb(0,172,238);
      background: linear-gradient(0deg, rgba(0,172,238,1) 0%, rgba(2,126,251,1) 100%);
        width: 130px;
        height: 40px;
        line-height: 42px;
        padding: 0;
        border: none;
        
      }
      .btn-3 span {
        position: relative;
        display: block;
        width: 100%;
        height: 100%;
      }
      .btn-3:before,
      .btn-3:after {
        position: absolute;
        content: "";
        right: 0;
        top: 0;
         background: rgba(2,126,251,1);
        transition: all 0.3s ease;
      }
      .btn-3:before {
        height: 0%;
        width: 2px;
      }
      .btn-3:after {
        width: 0%;
        height: 2px;
      }
      .btn-3:hover{
         background: transparent;
        box-shadow: none;
      }
      .btn-3:hover:before {
        height: 100%;
      }
      .btn-3:hover:after {
        width: 100%;
      }
      .btn-3 span:hover{
         color: rgba(2,126,251,1);
      }
      .btn-3 span:before,
      .btn-3 span:after {
        position: absolute;
        content: "";
        left: 0;
        bottom: 0;
         background: rgba(2,126,251,1);
        transition: all 0.3s ease;
      }
      .btn-3 span:before {
        width: 2px;
        height: 0%;
      }
      .btn-3 span:after {
        width: 0%;
        height: 2px;
      }
      .btn-3 span:hover:before {
        height: 100%;
      }
      .btn-3 span:hover:after {
        width: 100%;
      }
      
      /* 4 */
      .btn-4 {
        background-color: #4dccc6;
      background-image: linear-gradient(315deg, #4dccc6 0%, #96e4df 74%);
        line-height: 42px;
        padding: 0;
        border: none;
      }
      .btn-4:hover{
        background-color: #89d8d3;
      background-image: linear-gradient(315deg, #89d8d3 0%, #03c8a8 74%);
      }
      .btn-4 span {
        position: relative;
        display: block;
        width: 100%;
        height: 100%;
      }
      .btn-4:before,
      .btn-4:after {
        position: absolute;
        content: "";
        right: 0;
        top: 0;
         box-shadow: 4px 4px 6px 0 rgba(255,255,255,.9),
                    -4px -4px 6px 0 rgba(116, 125, 136, .2),
          inset -4px -4px 6px 0 rgba(255,255,255,.9),
          inset 4px 4px 6px 0 rgba(116, 125, 136, .3);
        transition: all 0.3s ease;
      }
      .btn-4:before {
        height: 0%;
        width: .1px;
      }
      .btn-4:after {
        width: 0%;
        height: .1px;
      }
      .btn-4:hover:before {
        height: 100%;
      }
      .btn-4:hover:after {
        width: 100%;
      }
      .btn-4 span:before,
      .btn-4 span:after {
        position: absolute;
        content: "";
        left: 0;
        bottom: 0;
        box-shadow: 4px 4px 6px 0 rgba(255,255,255,.9),
                    -4px -4px 6px 0 rgba(116, 125, 136, .2),
          inset -4px -4px 6px 0 rgba(255,255,255,.9),
          inset 4px 4px 6px 0 rgba(116, 125, 136, .3);
        transition: all 0.3s ease;
      }
      .btn-4 span:before {
        width: .1px;
        height: 0%;
      }
      .btn-4 span:after {
        width: 0%;
        height: .1px;
      }
      .btn-4 span:hover:before {
        height: 100%;
      }
      .btn-4 span:hover:after {
        width: 100%;
      }
      
      /* 5 */
      .btn-5 {
        width: 130px;
        height: 40px;
        line-height: 42px;
        padding: 0;
        border: none;
        background: rgb(255,27,0);
      background: linear-gradient(0deg, rgba(255,27,0,1) 0%, rgba(251,75,2,1) 100%);
      }
      .btn-5:hover {
        color: #f0094a;
        background: transparent;
         box-shadow:none;
      }
      .btn-5:before,
      .btn-5:after{
        content:'';
        position:absolute;
        top:0;
        right:0;
        height:2px;
        width:0;
        background: #f0094a;
        box-shadow:
         -1px -1px 5px 0px #fff,
         7px 7px 20px 0px #0003,
         4px 4px 5px 0px #0002;
        transition:400ms ease all;
      }
      .btn-5:after{
        right:inherit;
        top:inherit;
        left:0;
        bottom:0;
      }
      .btn-5:hover:before,
      .btn-5:hover:after{
        width:100%;
        transition:800ms ease all;
      }
      
      
      /* 6 */
      .btn-6 {
        background: rgb(247,150,192);
      background: radial-gradient(circle, rgba(247,150,192,1) 0%, rgba(118,174,241,1) 100%);
        line-height: 42px;
        padding: 0;
        border: none;
      }
      .btn-6 span {
        position: relative;
        display: block;
        width: 100%;
        height: 100%;
      }
      .btn-6:before,
      .btn-6:after {
        position: absolute;
        content: "";
        height: 0%;
        width: 1px;
       box-shadow:
         -1px -1px 20px 0px rgba(255,255,255,1),
         -4px -4px 5px 0px rgba(255,255,255,1),
         7px 7px 20px 0px rgba(0,0,0,.4),
         4px 4px 5px 0px rgba(0,0,0,.3);
      }
      .btn-6:before {
        right: 0;
        top: 0;
        transition: all 500ms ease;
      }
      .btn-6:after {
        left: 0;
        bottom: 0;
        transition: all 500ms ease;
      }
      .btn-6:hover{
        background: transparent;
        color: #76aef1;
        box-shadow: none;
      }
      .btn-6:hover:before {
        transition: all 500ms ease;
        height: 100%;
      }
      .btn-6:hover:after {
        transition: all 500ms ease;
        height: 100%;
      }
      .btn-6 span:before,
      .btn-6 span:after {
        position: absolute;
        content: "";
        box-shadow:
         -1px -1px 20px 0px rgba(255,255,255,1),
         -4px -4px 5px 0px rgba(255,255,255,1),
         7px 7px 20px 0px rgba(0,0,0,.4),
         4px 4px 5px 0px rgba(0,0,0,.3);
      }
      .btn-6 span:before {
        left: 0;
        top: 0;
        width: 0%;
        height: .5px;
        transition: all 500ms ease;
      }
      .btn-6 span:after {
        right: 0;
        bottom: 0;
        width: 0%;
        height: .5px;
        transition: all 500ms ease;
      }
      .btn-6 span:hover:before {
        width: 100%;
      }
      .btn-6 span:hover:after {
        width: 100%;
      }
      
      /* 7 */
      .btn-7 {
      background: linear-gradient(0deg, rgba(255,151,0,1) 0%, rgba(251,75,2,1) 100%);
        line-height: 42px;
        padding: 0;
        border: none;
      }
      .btn-7 span {
        position: relative;
        display: block;
        width: 100%;
        height: 100%;
      }
      .btn-7:before,
      .btn-7:after {
        position: absolute;
        content: "";
        right: 0;
        bottom: 0;
        background: rgba(251,75,2,1);
        box-shadow:
         -7px -7px 20px 0px rgba(255,255,255,.9),
         -4px -4px 5px 0px rgba(255,255,255,.9),
         7px 7px 20px 0px rgba(0,0,0,.2),
         4px 4px 5px 0px rgba(0,0,0,.3);
        transition: all 0.3s ease;
      }
      .btn-7:before{
         height: 0%;
         width: 2px;
      }
      .btn-7:after {
        width: 0%;
        height: 2px;
      }
      .btn-7:hover{
        color: rgba(251,75,2,1);
        background: transparent;
      }
      .btn-7:hover:before {
        height: 100%;
      }
      .btn-7:hover:after {
        width: 100%;
      }
      .btn-7 span:before,
      .btn-7 span:after {
        position: absolute;
        content: "";
        left: 0;
        top: 0;
        background: rgba(251,75,2,1);
        box-shadow:
         -7px -7px 20px 0px rgba(255,255,255,.9),
         -4px -4px 5px 0px rgba(255,255,255,.9),
         7px 7px 20px 0px rgba(0,0,0,.2),
         4px 4px 5px 0px rgba(0,0,0,.3);
        transition: all 0.3s ease;
      }
      .btn-7 span:before {
        width: 2px;
        height: 0%;
      }
      .btn-7 span:after {
        height: 2px;
        width: 0%;
      }
      .btn-7 span:hover:before {
        height: 100%;
      }
      .btn-7 span:hover:after {
        width: 100%;
      }
      
      /* 8 */
      .btn-8 {
        background-color: #f0ecfc;
      background-image: linear-gradient(315deg, #f0ecfc 0%, #c797eb 74%);
        line-height: 42px;
        padding: 0;
        border: none;
      }
      .btn-8 span {
        position: relative;
        display: block;
        width: 100%;
        height: 100%;
      }
      .btn-8:before,
      .btn-8:after {
        position: absolute;
        content: "";
        right: 0;
        bottom: 0;
        background: #c797eb;
        /*box-shadow: 4px 4px 6px 0 rgba(255,255,255,.5),
                    -4px -4px 6px 0 rgba(116, 125, 136, .2),
          inset -4px -4px 6px 0 rgba(255,255,255,.5),
          inset 4px 4px 6px 0 rgba(116, 125, 136, .3);*/
        transition: all 0.3s ease;
      }
      .btn-8:before{
         height: 0%;
         width: 2px;
      }
      .btn-8:after {
        width: 0%;
        height: 2px;
      }
      .btn-8:hover:before {
        height: 100%;
      }
      .btn-8:hover:after {
        width: 100%;
      }
      .btn-8:hover{
        background: transparent;
      }
      .btn-8 span:hover{
        color: #c797eb;
      }
      .btn-8 span:before,
      .btn-8 span:after {
        position: absolute;
        content: "";
        left: 0;
        top: 0;
        background: #c797eb;
        /*box-shadow: 4px 4px 6px 0 rgba(255,255,255,.5),
                    -4px -4px 6px 0 rgba(116, 125, 136, .2),
          inset -4px -4px 6px 0 rgba(255,255,255,.5),
          inset 4px 4px 6px 0 rgba(116, 125, 136, .3);*/
        transition: all 0.3s ease;
      }
      .btn-8 span:before {
        width: 2px;
        height: 0%;
      }
      .btn-8 span:after {
        height: 2px;
        width: 0%;
      }
      .btn-8 span:hover:before {
        height: 100%;
      }
      .btn-8 span:hover:after {
        width: 100%;
      }
相关文章
element中el-cascader级联 下拉选择-可单独多选(整理)
element中el-cascader级联 下拉选择-可单独多选(整理)
|
11天前
|
人工智能 IDE 双11
2026 年阿里云双 11 Qoder CN 优惠全梳理,免费试用、额度加赠、夜间 4 折玩法
整体来看,2026年阿里云双十一大促给Qoder CN带来了很实在的降价空间,从免费试用、个人订阅到企业私有化方案,梯度清晰。个人开发者优先先领免费额度试用,确认适配自己的开发语言和项目类型,再趁首月额度翻倍活动开通订阅;研发团队评估月度编码调用量,优先采购年包拿到折扣;有数据隔离需求的企业,直接咨询商务了解VPC部署方案。搭配夜间4折的模型优惠,合理安排任务执行时间,能够把AI编码的长期使用成本控制到更低,是提升研发效率的高效方案。
200 0
|
3月前
|
存储 数据采集 人工智能
大模型长效迭代:构建离线评测、回归测试、线上监控、人工反馈一体化持续优化体系23.9
本文提出大模型落地必备的标准化评估与迭代闭环体系,涵盖离线评测、在线观测、回归测试、人工反馈四大模块。通过统一数据结构、多维指标(效果/性能/成本/业务)和自动化流程,实现问题驱动、数据闭环的持续优化,解决上线后幻觉增多、能力退化、成本飙升等痛点,支撑模型可靠、高效、可持续演进。
475 2
|
3月前
|
JSON 编解码 前端开发
1688 拍立淘 API(1688.item_search_img)图片搜索完整使用流程
适用于企业B端采购寻源与样品比价,通过上传样品图,调用1688拍立淘API(item_search_img)精准匹配同款/相似货源,返回商品ID、标题、主图、相似度及商家信息;再结合商品详情API获取价格、MOQ、交期等完成自动化比价。
462 1
|
3月前
|
存储 人工智能 自然语言处理
千问办公实测:一句话替你干活的AI Agent,来自阿里QwenWork千问办公个人免费使用!
阿里云千问办公QwenWork是面向办公场景的AI智能体平台,支持自然语言一键生成PPT/Word/Excel/网页、钉钉深度集成、多模态理解与浏览器自动化等六大能力,提供免费版及多种付费版本,真正实现“一句话交付成果”。阿里千问办公QwenWork官网:https://t.aliyun.com/U/JNKJuO 阿里AI工作平台,一句话完成数据分析、PPT 生成、视频剪辑、网页搭建等复杂任务
|
3月前
|
JSON 监控 安全
简电云 | 充电平台基于中电联协议互联互通的设计与实现
本文详解中电联充换电信息交换协议的工程落地实践,聚焦平台间数据互通难点:协议版本统一、加密签名验签、状态机设计与订单追溯。提出分层网关架构,涵盖安全处理、接口分组、异步通知、幂等控制及对账校验,强调以版本基线和可复核性保障长期稳定对接。
|
4月前
|
人工智能 Linux iOS开发
【2026最新】Zed编辑器中文版+安装+AI辅助写代码一篇搞定
Zed编辑器是Atom原班团队打造的高性能开源代码编辑器,启动秒开、输入零延迟,深度优化多核与GPU加速。内置AI编程助手、原生多人协作,界面简洁无干扰,支持Windows/macOS/Linux,免费开源,被誉为“最后一代编辑器”。
|
人工智能 前端开发 Java
2025 开发必备:精选免费 AI 辅助工具,效率狂飙不停
2025年,AI技术深度融入编程领域,诞生了多款免费且功能强大的辅助工具。通义灵码精通200多种语言,可快速生成代码框架,提升开发效率超10%,还为新手提供学习指导。Google Gemini Code Assist每月完成18万次代码补全,支持智能交互与代码审查,优化团队协作。飞算JavaAI专注Java全流程开发,从需求分析到代码生成实现十倍提效。这些工具大幅降低编程门槛,助力开发者高效高质完成任务。
|
存储 移动开发 JavaScript
网页 HTML 自动播放下一首音乐
在 HTML5 中实现自动播放下一首音乐,通过管理音乐列表、操作音频元素和监听事件完成。创建包含多个音乐链接的列表,使用 `&lt;audio&gt;` 元素加载音乐,监听 `ended` 事件,在当前音乐结束时自动播放下一首。示例代码展示了如何使用 JavaScript 实现这一功能,确保无缝切换音乐。
|
Kubernetes 监控 API
在K8S中,什么是静态Pod、自主式Pod、动态Pod?
在K8S中,什么是静态Pod、自主式Pod、动态Pod?