html+css 实现hover 3D按钮特效

前言:哈喽,大家好,今天给大家分享html+css 绚丽效果!并提供具体代码帮助大家深入理解,彻底掌握!创作不易,如果能帮助到大家或者给大家一些灵感和启发,欢迎收藏+关注哦 💕

目录

一、效果

二、原理解析

1.这是一个,hover 3D悬浮的按钮效果。每个按钮都是由5部分组成,a,a:before,a:after,i,span如下图。

2.当按钮上有鼠标时,hover效果触发,运行transition过渡动画和其他属性变化效果。

css 复制代码
/*当hover时*/
a:hover {
    transform: rotate(-30deg) skew(25deg) translate(20px, -15px);
    box-shadow: -50px 50px 50px rgba(0, 0, 0, 0.5);
}

a:hover .iconfont {
    color: #fff;
}

a:hover span {
    color: #fff;
}

a:hover {
    background: #dd4b39;
}

a:hover:before {
    background: #b33a2b;
}

a:hover:after {
    background: #e66a5a;
}

3.具体的变换参数,直接看代码,可以一键复制,查看效果

三、上代码,可以直接复制使用

目录

html

html 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>html+css 实现hover 3D按钮特效</title>
    <link rel="stylesheet" href="https://at.alicdn.com/t/c/font_4646876_7vpdpyxzi9o.css">
    <link rel="stylesheet" href="./style.css">
</head>
<body>
<div class="container">
    <h1 style="text-align: center;color:#fff;margin-bottom: 50px;padding-top: 50px; text-shadow: 0 3px 3px #4c6ed3;">
        html+css 实现hover 3D按钮特效</h1>

    <div class="wrapper">
        <a href="#">
            <i class="iconfont">&#xe63b;</i>
            <span>-求点赞</span>
        </a>
        <a href="#">
            <i class="iconfont">&#xe621;</i>
            <span>-求关注</span>
        </a>
        <a href="#">
            <i class="iconfont">&#xe627;</i>
            <span>-求收藏</span>
        </a>
        <a href="#">
            <i class="iconfont">&#xe628;</i>
            <span>-求转发</span>
        </a>
    </div>
</div>

</body>
</html>

css

css 复制代码
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --btn-bg-color: #fff;
    --font-color-black: #000;
    --btn-bg-color-hover: #FF5833;
}

.container {
    min-height: 100vh;
    background-color: #CCCCCC;
}

.wrapper {
    margin-top: 150px;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 40px;
}

a .iconfont {
    font-size: 40px;
    color: #333;
    line-height: 80px;
    transition: 0.5s;
    padding-right: 14px;
}

a span {
    padding: 0;
    margin: 0;
    position: absolute;
    top: 30px;
    color: #333;
    letter-spacing: 4px;
    transition: 0.5s;
}


a {
    text-decoration: none;
    position: relative;
    display: block;
    width: 210px;
    height: 80px;
    background: #fff;
    text-align: left;
    padding-left: 20px;
    transform: rotate(-30deg) skew(25deg) translate(0, 0);
    transition: 0.5s;
    box-shadow: -20px 20px 10px rgba(0, 0, 0, 0.5);
}

a:before {
    content: '';
    position: absolute;
    top: 10px;
    left: -20px;
    height: 100%;
    width: 20px;
    background: #b1b1b1;
    transform: 0.5s;
    transform: rotate(0deg) skewY(-45deg);
}

a:after {
    content: '';
    position: absolute;
    bottom: -20px;
    left: -10px;
    height: 20px;
    width: 100%;
    background: #b1b1b1;
    transform: 0.5s;
    transform: rotate(0deg) skewX(-45deg);
}

/*当hover时*/
a:hover {
    transform: rotate(-30deg) skew(25deg) translate(20px, -15px);
    box-shadow: -50px 50px 50px rgba(0, 0, 0, 0.5);
}

a:hover .iconfont {
    color: #fff;
}

a:hover span {
    color: #fff;
}

a:hover {
    background: #dd4b39;
}

a:hover:before {
    background: #b33a2b;
}

a:hover:after {
    background: #e66a5a;
}

到此这篇文章就介绍到这了,更多精彩内容请关注本人以前的文章或继续浏览下面的文章,创作不易,如果能帮助到大家,希望大家多多支持宝码香车~💕

更多专栏订阅推荐:

👍 html+css+js 绚丽效果

💕 vue

✈️ Electron

⭐️ js

📝 字符串

✍️ 时间对象(Date())操作

相关推荐
子兮曰4 天前
jev-ultrafast 深度解析:7 秒订机票的浏览器 Agent 是如何炼成的
前端·后端·agent
子兮曰4 天前
Jev 爆发一周:7 秒 Agent 背后的 System One 生态与三场争议
前端·后端·ai编程
前端小万4 天前
写公众号赚了 3000 块后,我做了一款叫 "一键成稿" 的软件
前端·微信小程序
爱勇宝4 天前
ZCode 开源 24 小时:一份没有历史的账本,回答不了"有没有偷代码"
前端·后端·chatglm (智谱)
三十而立洋4 天前
Cookie 详解:从产生到安全,一次讲透
前端·javascript
卡布鲁4 天前
把一个 Vite + Vue3 应用塞进 qiankun (React + Umi3) 主站:十个坑的复盘
前端·javascript·react.js
汉堡大王95274 天前
Jev:不是聊天机器人, 而是一个智能 if 语句
前端·人工智能·后端
梦想很大很大4 天前
从运行事实到回归证据:Workrun 的 Telemetry 与 Evaluation 实践
前端·人工智能·后端
计算机魔术师4 天前
Meta Muse agent 接入 Shopify 的 Shop Pay 实现代理式购物
前端
沙蒿同学4 天前
我用 Go 搭了一条 AI Agent 流水线:从 1 张商品图到一整套淘宝详情页
前端·javascript·后端