渡一教育公开课web前端开发JavaScript精英课学习笔记(三十三)jQuery CSS 四叶草菜单

jQuery CSS 四叶草菜单

<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>jQuery四叶草菜单</title>
    <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.js"></script>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        body,
        html {
            width: 100%;
            height: 100%;
            display: flex;
            justify-content: center;
            align-items: center;
            background-color: rgb(236, 172, 234);
        }

        .container {
            position: relative;
            width: 400px;
            height: 400px;

        }

        .button {
            position: absolute;
            width: 150px;
            height: 150px;
            background-color: peru;
            text-align: center;
            line-height: 150px;
            font-size: 36px;
            color: #fff;
            transition: all 0.3s;
        }

        .button:hover {
            box-shadow: 0 0 10px rgb(102, 98, 98);
        }

        .button.one {
            left: 45px;
            top: 45px;
            border-top-right-radius: 50%;
            border-bottom-left-radius: 50%;
            background-color: rgba(255, 95, 96, .85);
        }

        .button.two {
            right: 45px;
            top: 45px;
            border-top-left-radius: 50%;
            border-bottom-right-radius: 50%;
            background-color: rgba(255, 255, 32, .85);
        }

        .button.three {
            left: 45px;
            bottom: 45px;
            border-top-left-radius: 50%;
            border-bottom-right-radius: 50%;
            background-color: rgba(170, 255, 28, .85);
        }

        .button.four {
            right: 45px;
            bottom: 45px;
            border-top-right-radius: 50%;
            border-bottom-left-radius: 50%;
            background-color: rgba(32, 212, 255, .85);
        }

        .button.one:hover,
        .button.two:hover {
            top: 35px;
        }

        .button.three:hover,
        .button.four:hover {
            bottom: 35px;
        }

        .button.one:hover,
        .button.three:hover {
            left: 35px;
        }

        .button.two:hover,
        .button.four:hover {
            right: 35px;
        }

        .click {
            border: 3px solid #fff;
            border-radius: 50%;
        }

        .button.one.click {
            left: 0px;
            top: 0px;
            background-color: rgb(255, 55, 55);
        }

        .button.two.click {
            right: 0px;
            top: 0px;
            background-color: rgb(243, 208, 11);
        }

        .button.three.click {
            left: 0px;
            bottom: 0px;
            background-color: rgb(81, 255, 28);
        }

        .button.four.click {
            right: 0px;
            bottom: 0px;
            background-color: rgb(32, 173, 255);
        }
    </style>
</head>

<body>

    <main class="container">
        <div data-back-color='rgba(255, 95, 96, .2)' class="button one">医疗</div>
        <div data-back-color='rgba(255, 255, 32, .2)' class="button two">饮食</div>
        <div data-back-color='rgba(170, 255, 28, .2)' class="button three">健身</div>
        <div data-back-color='rgba(32, 212, 255, .2)' class="button four">消费</div>
    </main>

    <script>
        $(".button").on('click', (event) => {
            if ($(event.target).hasClass('click')) {
                $(event.target).removeClass('click');
            } else {
                $(".button").removeClass('click');
                $(event.target).addClass('click');
                $('body').css('background-color',$(event.target).attr('data-back-color'));
            }
        });
    </script>
</body>

</html>

 

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值