【css酷炫效果】纯CSS实现悬浮弹性按钮

【css酷炫效果】纯CSS实现悬浮弹性按钮

想直接拿走的老板,链接放在这里:https://download.csdn.net/download/u011561335/90492020

创作随缘,不定时更新。

创作背景

刚看到csdn出活动了,赶时间,直接上代码。

html结构

clike 复制代码
    <button class="elastic-button">点我点我!</button>

css样式

clike 复制代码
        body {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
            background-color: #f0f0f0;
        }
 
        .elastic-button {
            padding: 15px 30px;
            font-size: 16px;
            color: #fff;
            background-color: #007BFF;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.27, 1.55), box-shadow 0.3s cubic-bezier(0.68, -0.55, 0.27, 1.55);
        }
 
        .elastic-button:hover {
            transform: translateY(-10px);
            box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
        }
 
        .elastic-button:active {
            transform: translateY(2px);
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
            transition: transform 0.1s, box-shadow 0.1s;
        }

完整代码

clike 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CSS Elastic Button</title>
    <style>
        body {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
            background-color: #f0f0f0;
        }
 
        .elastic-button {
            padding: 15px 30px;
            font-size: 16px;
            color: #fff;
            background-color: #007BFF;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.27, 1.55), box-shadow 0.3s cubic-bezier(0.68, -0.55, 0.27, 1.55);
        }
 
        .elastic-button:hover {
            transform: translateY(-10px);
            box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
        }
 
        .elastic-button:active {
            transform: translateY(2px);
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
            transition: transform 0.1s, box-shadow 0.1s;
        }
    </style>
</head>
<body>
    <button class="elastic-button">点我点我!</button>
</body>
</html>

效果图

相关推荐
IT_陈寒几秒前
React 18 性能优化实战:5个被低估的Hooks用法让你的应用快30%
前端·人工智能·后端
阿珊和她的猫7 分钟前
页面停留时长埋点实现技术详解
开发语言·前端·javascript·ecmascript
chilavert31810 分钟前
技术演进中的开发沉思-275 AJax : Slider
前端·javascript·ajax·交互
梦65016 分钟前
基于 Vue3 + TypeScript 封装 UEditor 富文本编辑器组件
前端·vue.js·typescript
沛沛老爹16 分钟前
从Web开发到AI应用——用FastGPT构建实时问答系统
前端·人工智能·langchain·rag·advanced-rag
锥锋骚年17 分钟前
Vue 3 Vben Admin 框架的Mention提及组件
前端·javascript·vue.js
QT 小鲜肉17 分钟前
【Linux命令大全】001.文件管理之mlabel命令(实操篇)
linux·运维·服务器·前端·笔记
七月巫山晴18 分钟前
【iOS】OC中的一些宏
前端·ios·objective-c
elangyipi12319 分钟前
从嵌套依赖到符号链接:4款主流npm包管理器的架构演进与深度对比
前端·架构·npm
武帝为此25 分钟前
【Shell脚本函数介绍】
前端·chrome