JavaScript的弹窗

JavaScript的弹窗

JavaScript的弹窗

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>js的弹窗</title>
</head>
<!-- 弹窗的css -->
<style>
    #alert-box{
        width: 100%;
        height: 100%;
        /*border-top-left-radius: 10px;*/
        /*border-top-right-radius: 10px;*/
        background: #f5f5f5;
        position: fixed;
        left: 100%;
        bottom: 0;
        top: 0;
    }
    #alert-box .header{
        padding: 10px;
        box-sizing: border-box;
        position: relative;
        height: 40px;
        background-color: #fff;
    }
    #alert-box .header .headerTitle{
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
    }
    @keyframes slideUp {
        from{
            left: 0;
        }
        to{
            left: 100%;
        }
    }
    @keyframes slideDown {
        from{
            left: 100%;
        }
        to{
            left: 0;
        }
    }
    #alert-box #close{
        font-size: 16px;
    }
    #alert-box .alert-content{
    }
    #alert-box .alert-content {
        background-color: #f5f5f5;
    }
    #alert-box .alert-content .commit-box {
        padding: 0 10px;
        margin-top: 20px;
    }
    #alert-box .alert-content .commit-box .commit {
        display: block;
        margin: 0 auto;
        text-align: center;
        width: 100%;
        height: 40px;
        line-height: 40px;
        background-color: #06f;
        border-radius: 5px;
        color: #fff;
    }
</style>
<body>
<div class="Index">
    <button class="btn">click me</button>
    <!-- 弹窗 -->
    <div id="alert-box">
        <div class="header">
            <span id="close">&lt;&nbsp;取消</span>
            <span class="headerTitle">标题</span>
        </div>
        <div class="alert-content">
            <div>我是内容</div>
            <div class="commit-box">
                <span class="commit">提交</span>
            </div>
        </div>
    </div>
</div>
</body>
<!--JQuery-->
<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
<script type="text/javascript">
    window.onload = function () {
        // 弹窗
        $('.btn').click(function () {
            $("#alert-box").animate({
                left: "0%",
                animation: "slideDown 0.5s 1 normal forwards",
            }, 500);
        });
        $('#close').click(function () {
            $("#alert-box").animate({
                left: "100%",
                animation: "slideDown 0.5s 1 normal forwards",
            }, 500);
        });
        // 提交
        $('.commit').click(function () {
            $("#alert-box").animate({
                left: "100%",
                animation: "slideDown 0.5s 1 normal forwards",
            }, 500);
        })
    };

</script>
</html>


结果

执行中执行结束
在这里插入图片描述$1600
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

码上暴富

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值