纯css3实现可按下动效按钮

效果如下:
在这里插入图片描述
css代码:

<style>
        body {
            background: #272822;
            margin: 0;
            perspective: 600px;
            -webkit-perspective: 600px;
        }

        /* Button container */

        .container {
            margin: 15px auto;
            width: 240px;
            height: 240px;
            transform: rotateX(40deg);
            transform-style: preserve-3d;
        }

        /* Light gray bottom part */

        .base {
            background: #bbb;
            border-radius: 16px;
            box-shadow: 0 -6px 0px #777777 inset;
            display: flex;
            display: -webkit-flex;
            justify-content: center;
            -webkit-justify-content: center;
            align-items: center;
            -webkit-align-items: center;
            position: relative;
            transform-style: preserve-3d;
            width: 240px;
            height: 240px;
        }

        /* Clickable area containing both dark gray parts of button */

        .btn-wrapper {
            border: 0;
            background: transparent;
            cursor: pointer;
            -webkit-appearance: none;
        }

        .btn-wrapper:active .btn {
            transform: translateZ(1px);
        }

        .btn-wrapper:active .btn-side {
            transform: translateZ(0);
        }

        .btn-wrapper:focus {
            outline: none;
        }

        /* Top of button */

        .btn {
            background: #444 linear-gradient(#888888, transparent 50%);
            border-radius: 16px;
            box-shadow: 0 0 5px #888888 inset;
            color: #f80;
            display: block;
            font: 178.5px Asap;
            font-weight: bold;
            width: 210px;
            height: 210px;
            transform: translateZ(36px);
            transition: all 0.05s;
            text-align: center;
            text-shadow: 0 0 24px #f80, 0 -2.4px 0 #222222, 0 2.4px 0 #ffbb33;
            z-index: 2;
            -webkit-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
        }

        /* Shown side of button */

        .btn-side {
            background: #333333 linear-gradient(90deg, #666666, transparent 8%, transparent 92%, #666666);
            border-radius: 0 0 12px 12px;
            box-shadow: 0 -4.8px 4.8px #222 inset;
            position: absolute;
            bottom: 8%;
            transform: rotateX(-60deg);
            transform-origin: 0 100%;
            transition: all 0.05s;
            width: 210px;
            height: 31.5px;
            z-index: 1;
        }
    </style>

html代码:

        <div class='container'>
            <div class='base'>
                <button class='btn-wrapper' ontouchstart=''>
                    <div class='btn-side'></div>
                    <div class='btn'>
                        S
                    </div>
                </button>
            </div>
        </div>

源码地址: 直达

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值