jquery-div提示框渐隐弹出与隐藏

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>jquery div提示框渐隐弹出与隐藏</title>
    <script type="text/javascript" src="jquery.min.js"></script>
    <style>
        * {
            margin: 0;
            padding: 0;
            font-size: 12px;
        }

        input {
            width: 120px;
            height: 30px;
            cursor: pointer;
        }

        #note {
            position: absolute;
            width: 400px;
            padding: 20px;
            background: #eee;
            border: 1px solid #ccc;
            left: 40%;
            z-index: 9999;
            display: none;
        }
    </style>
    <script>
        $(function () {
            $('input').click(function () {
                if (!$('#note').is(':visible')) {
                    $('#note').css({display: 'block', top: '-100px'}).animate({top: '+100'}, 500, function () {
                        setTimeout(out, 3000);
                    });
                }
            });
        });

        function out() {
            $('#note').animate({top: '0'}, 500, function () {
                $(this).css({display: 'none', top: '-100px'});
            });
        }
    </script>
</head>
<body>

<div id="note"><a href="http://www.jb51.net" target="_blank">脚本之家</a></div>
<input type="button" value="点我,30s后消失">

</body>
</html>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,我可以为你提供一个示例代码,使用 jquery-confirm 插件实现弹出框缩小后出现在右侧边缘,恢复后出现在中间区域。 首先,你需要引入 jquery-confirm 插件和 jQuery 库。然后,使用以下代码创建一个弹出框: ```html <div id="my-confirm" class="my-confirm"> <h4>提示</h4> <p>这是一个弹出框</p> </div> ``` 接下来,你可以使用以下 JavaScript 代码初始化 jquery-confirm 插件,并设置弹出框缩小和恢复的回调函数: ```javascript $(document).ready(function() { // 初始化 jquery-confirm 插件 $.confirm({ title: '', content: $('#my-confirm'), columnClass: 'medium', draggable: true, dragWindowGap: 0, onContentReady: function() { var self = this; this.$content.find('.btn-minimize').click(function() { // 缩小弹出框 self.$content.parent().removeClass('medium').addClass('small'); self.$content.parent().css({ top: $(window).height() - self.$content.parent().outerHeight() - 50, left: $(window).width() - self.$content.parent().outerWidth() - 50 }); }); this.$content.find('.btn-maximize').click(function() { // 恢复弹出框 self.$content.parent().removeClass('small').addClass('medium'); self.$content.parent().css({ top: ($(window).height() - self.$content.parent().outerHeight()) / 2, left: ($(window).width() - self.$content.parent().outerWidth()) / 2 }); }); } }); }); ``` 在这个示例中,我们首先初始化了 jquery-confirm 插件,并使用 content 属性指定了弹出框的内容。然后设置 draggable 属性为 true,允许用户拖动弹出框。同时设置 dragWindowGap 属性为 0,使弹出框拖动时与鼠标指针对齐。 接着,我们在 onContentReady 回调函数中获取弹出框的按钮元素,并为按钮元素绑定了 click 事件。在缩小按钮的 click 事件中,我们使用 jQuery 的 css() 方法设置了弹出框的位置,使其出现在右侧边缘。在恢复按钮的 click 事件中,我们同样使用 css() 方法设置了弹出框的位置,使其出现在中间区域。 最后,我们在 HTML 中为弹出框添加了两个按钮,分别是缩小和恢复按钮: ```html <button class="btn-minimize">缩小</button> <button class="btn-maximize">恢复</button> ``` 希望这个示例代码能够帮助你实现弹出框缩小后出现在右侧边缘,恢复后出现在中间区域的效果。如果还有其他问题,欢迎继续提问。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值