许愿墙JQ

<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <title>1</title>
    <style>
        body {
            background: -webkit-linear-gradient(top, rgb(203, 235, 219) 0%, rgb(55, 148, 192) 120%);
            background: -moz-linear-gradient(top, rgb(203, 235, 219) 0%, rgb(55, 148, 192) 120%);
            overflow: hidden;
            font-family: '微软雅黑';
            font-size: 16px;
            height: 1500px;
        }

        .item {
            width: 200px;
            height: 200px;
            line-height: 30px;
            box-shadow: 0 2px 10px 1px rgba(0, 0, 0, 0.2);
            -webkit-box-shadow: 0 2px 10px 1px rgba(0, 0, 0, 0.2);
            -moz-box-shadow: 0 2px 10px 1px rgba(0, 0, 0, 0.2);
        }

        #container p {
            height: 80px;
            margin: 30px 10px;
            overflow: hidden;
            word-wrap: break-word;
            line-height: 1.5;
        }

        #container a {
            position: relative;
            left: 150px;
            color: red;
            font-size: 14px;
        }

        input {
            display: block;
            height: 30px;
            padding: 0 1em;
            line-height: 30px;
            width: 300px;
            margin: 85px auto;
            font-size: 20px;
        }
    </style>
    <script src="jquery-3.4.1.min.js"></script>
    <script>
        (function ($) {
            var container;
            var colors = ['#96C2F1', '#BBE1F1', '#E3E197', '#F8B3D0', '#FFCC00'];
            var createItem = function (text) {
                var color = colors[parseInt(Math.random() * 5, 10)]
                $('<div class="item"><p>' + text + '</p><a href="#">关闭</a></div>').css({ 'background': color }).appendTo(container).drag();
            };
            $.fn.drag = function () {
                var $this = $(this);
                var parent = $this.parent();
                var pw = parent.width();
                var ph = parent.height();
                var thisWidth = $this.width() + parseInt($this.css('padding-left'), 10) + parseInt($this.css('padding-right'), 10);
                var thisHeight = $this.height() + parseInt($this.css('padding-top'), 10) + parseInt($this.css('padding-bottom'), 10);
                var x, y, positionX, positionY;
                var isDown = false;
                var randY = parseInt(Math.random() * (ph - thisHeight), 10);
                var randX = parseInt(Math.random() * (pw - thisWidth), 10);
                parent.css({
                    "position": "relative",
                    "overflow": "hidden"
                });
                $this.css({
                    "cursor": "move",
                    "position": "absolute"
                }).css({
                    top: randY,
                    left: randX
                }).mousedown(function (e) {
                    parent.children().css({
                        "zIndex": "0"
                    });
                    $this.css({
                        "zIndex": "1"
                    });
                    isDown = true;
                    x = e.pageX;
                    y = e.pageY;
                    positionX = $this.position().left;
                    positionY = $this.position().top;
                    return false;
                });
                $(document).mouseup(function (e) {
                    isDown = false;
                }).mousemove(function (e) {
                    var xPage = e.pageX;
                    var moveX = positionX + xPage - x;

                    var yPage = e.pageY;
                    var moveY = positionY + yPage - y;

                    if (isDown == true) {
                        $this.css({
                            "left": moveX,
                            "top": moveY
                        });
                    } else {
                        return;
                    }
                    if (moveX < 0) {
                        $this.css({
                            "left": "0"
                        });
                    }
                    if (moveX > (pw - thisWidth)) {
                        $this.css({
                            "left": pw - thisWidth
                        });
                    }
                    if (moveY < 0) {
                        $this.css({
                            "top": "0"
                        });
                    }
                    if (moveY > (ph - thisHeight)) {
                        $this.css({
                            "top": ph - thisHeight
                        });
                    }
                });
            };
            var init = function () {
                container = $('#container');
                container.on('click', 'a', function () {
                    $(this).parent().remove();
                }).height(($(window).height() - 200) < 0 ? 520 : ($(window).height() - 200))
                    .width(($(window).width() - 200) < 0 ? '100%' : $(window).width());

                var tests = ['能找一份好工作', '日语等级考试通过', '能交上女朋友', '新年来好运', '中大奖'];
                $.each(tests, function (i, v) {
                    createItem(v);
                });
                $('#input').keydown(function (e) {
                    var $this = $(this);
                    if (e.keyCode == '13') {
                        var value = $this.val();
                        if (value) {
                            createItem(value);
                            $this.val('');
                        }
                    }
                });
            };
            $(function () {
                init();
            });
        })(jQuery);
    </script>
</head>

<body>
    <div id="container" style="height:520px;"></div>
    <input id="input" type="text" placeholder="随便说说吧...按回车键发布" />
</body>

</html>

转载于:https://www.cnblogs.com/yeyuyuni/p/11586582.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
小王许愿墙(仿QQ爱墙)是爱墙网原创开发的简洁、安全、稳定、高效的ASP祝福墙(许愿墙)程序。 小王许愿墙(仿QQ爱墙) 1.6 更新内容: 采用"DIV CSS"网页标准构建,代码十分简洁; 更新整个页面使其更加酷炫; 加入导航链接后台,方便管理 自定义脏话、敏感字词过滤、每页显示条数、列表条数、防灌水防刷间隔时间; 入库数据实现完善过滤,IP追踪; 含搜索功能、无序和列表浏览方式;管理员登录后可修改密码或删除帖子;  支持主流浏览器如IE、Firefox等 后台地址:login.asp; 默认用户/密码:654364200 功能特色: 采用"DIV CSS"网页标准构建,代码十分简洁; 免费版本自带仿QQ爱墙风格,但不包括动态QQ图案; 自定义脏话、敏感字词过滤、每页显示条数、列表条数、防灌水防刷间隔时间; 入库数据实现完善过滤,IP追踪; 含搜索功能、无序和列表浏览方式;管理员登录后可修改密码或删除帖子;  支持主流浏览器如IE、Firefox等 首次使用,如何设置参数? -请打开_conn.asp文件,按照里面的说明修改相关参数,除了你的网站名称之外,一般不用改动。 如何从1.1升级到1.5? -请先下载1.5,然后用你1.1程序的数据库,直接覆盖1.5里的数据库文件_lovewall。 如何修改用户名及密码? -请先登录后台,在进入的页面下方有“修改密码”。 如何更换网站logo? -请制作自己的flash动画logo,覆盖images下的logo文件。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值