day 39 假直播间弹幕

上代码

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <style>
        *{
            list-style: none;
        }
        body {
            width: 1200px;
            height: 540px;
        }
        .left{
            width: 1000px;
            height: 540px;
            float: left;
        }
        .video {
            width: 1000px;
            height: 500px;
            background-color: #cccccc;
            line-height: 500px;
            text-align: center;
            color: black;
            font-size: 22px;
            float: left;
        }

        .video label {
            cursor: pointer;
        }

        .danMu {
            height: 40px;
            width: 1000px;
            background-color: gainsboro;
            float: left;
        }

        .shuRu {
            float: left;
            height: 40px;
            width: 600px;
            text-align: center;
            line-height: 40px;
        }

        .shuRu input {
            height: 32px;
            float: right;
        }

        .faShe button {
            float: right;
            width: 100px;
            height: 40px;
            background-color: #f90000;
            text-align: center;
            font-size: 22px;
            line-height: 40px;
            margin-right: 300px;
            color: whitesmoke;
        }

        .danmuQiang {
            float: right;
            width: 200px;
            height: 540px;
            background-color: snow;
            font-size: 12px;
        }
        span {
            height: 40px;
            position: absolute;
            overflow: hidden;
            color: #000;
            font-size: 20px;
            line-height: 1.5em;
            cursor: pointer;
            white-space: nowrap;
            z-index: 999;
        }
    </style>
</head>
<body>
<div class="left">
    <div class="video"><label>主播正在赶来,请先去看看其他直播间哦</label></div>
    <div class="danMu" id="danMU">
        <div class="shuRu"><input type="text" placeholder="请注意文明发言" id="text" size="35"></div>
        <div class="faShe">
            <button id="btn">发射</button>
        </div>
    </div>
</div>
<div class="danmuQiang">
    <ul id="ul">

    </ul>
</div>
</body>
</html>
<script src="js/jquery-1.12.4.js"></script>
<script>
    $("#btn").click(function () {
        var width = $("body").width();
        var value = $("#text").val();
        var span = $("<span></span>");
        span.appendTo($(".video"));
        span.text(value)
                .css("color", color())
                .css("top", height())
                .css("left", width-$(".danmuQiang").width()-$(span).width())
                .animate({"left": -$(span).width()}, 3000, function () {
                    $(this).remove()
                });
        if(value==""){
            return;
        }else{
            $("<li></li>").text(value).prependTo("ul");
        }
    })
    function color() {
        var color = "";
        var colors = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, "a", "b", "c", "d", "e", "f"];
        for (var i = 0; i < 6; i++) {
            var n = Math.ceil(Math.random() * 15);
            color += "" + colors[n];
            if (i == 5) {
                return "#" + color;
            }
        }
    }
    function height() {
        return Math.floor(Math.random() * 395);
    }
    $("#text").keyup(function (e) {
        if (e.keyCode == 13) {
            $("#btn").click();
        }
    })



</script>

完事~

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值