国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > JavaScript > 正文

又一枚精彩的彈幕效果jQuery實(shí)現(xiàn)

2019-11-20 09:25:08
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

簡(jiǎn)易彈幕效果:將發(fā)布的內(nèi)容隨機(jī)顯示在彈幕右側(cè),逐漸左移最后消失。

涉及知識(shí)點(diǎn):val()、random()、height()、css()、append()、remove()等,主要是元素的操作

html代碼:

<a href="#">彈幕技術(shù)</a>  <div class="mask">    <a href="#" class="button">X</a>  </div>  <!-- 底部發(fā)言框前端 -->  <div class="bottom">    <input class="content"></input>    <a href="#" class="send">發(fā)表言論</a>  </div>

css代碼:

html,body{    background-image:url("images/208.jpg");    height:100%;//文字的顯示區(qū)域要設(shè)置好  }  div.mask{    position:fixed;    width:100%;    height:100%;    background-color:black;    opacity:0.5;    top:0px;    left:0px;  }  div.bottom{    width:100%;    height:77px;    background-color:#090909;    position:fixed;    bottom:0px;    left:0px;    text-align:center;    line-height:77px;  }  div.bottom input.content{    width:605px;    height:37px;    border:none;    border-radius:10px 0px 0px 10px;    font-size:16px;    font-family:'Microsoft Yahei';  }  div.bottom a.send{    background-color:green;    color:#fff;    display:inline-block;    width:150px;    height:40px;    line-height:37px;    text-align:center;    position:relative;    left:-10px;    top:-2px;    border-radius:0px 10px 10px 0px;    text-decoration:none;    font-family:'Microsoft Yahei';  }  div.mask a.button{    width:50px;    height:50px;    border-radius:30px;    background-color:#660000;    color:#fff;    position:fixed;    top:20px;    right:20px;    text-align:center;    line-height:50px;    font-size:30px;    font-family:'Microsoft Yahei';    border:1px solid #fff;    text-decoration:none;    cursor:pointer;  }  div.text{    color:#fff;    position:fixed;    right:0px;    font-size:20px;    white-space: nowrap;  }

jQuery代碼:

$('a.send').click(function(){      //獲取內(nèi)容,創(chuàng)建新元素,并設(shè)置位置追加到目標(biāo)元素中      var val=$('input.content').val();      var $content=$('<div class="text">'+val+'</div>');      var top=Math.random()*$(document.body).height()-77;      $content.css('top',top);      $('div.mask').append($content);      //移動(dòng)到最右側(cè),直接刪除該元素      $content.animate({right:$(document.body).width()+100},8000,function(){        $(this).remove();      });    });    $('div.button').click(function(){      $('div.mask').hide(2000);    });

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持武林網(wǎng)。

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 禹城市| 神木县| 澄江县| 兴仁县| 永定县| 岗巴县| 疏勒县| 方城县| 周口市| 元朗区| 永清县| 文安县| 阿合奇县| 洞口县| 六枝特区| 鹤庆县| 汨罗市| 河西区| 道孚县| 溧水县| 施秉县| 阿合奇县| 新密市| 六盘水市| 门源| 界首市| 磴口县| 达州市| 永登县| 商洛市| 海南省| 余庆县| 麦盖提县| 若尔盖县| 曲阜市| 都昌县| 龙山县| 大关县| 新疆| 麻江县| 麻江县|