最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

jQuery實(shí)現(xiàn)彈幕特效

 更新時(shí)間:2019年11月29日 08:27:34   作者:有一個(gè)進(jìn)大廠的夢  
這篇文章主要為大家詳細(xì)介紹了jQuery實(shí)現(xiàn)彈幕特效,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

案例簡介

jQuery實(shí)現(xiàn)彈幕效果,代碼如下。

案例目錄

HTML部分

<!DOCTYPE html>


<html>
 <head>
 <meta charset="utf-8">
 <title>jQuery彈幕案例</title>
 <link rel="stylesheet" type="text/css" href="style.css" rel="external nofollow" />
 </head>
 <body>
 <div class="box">
 <div class="top"></div>
 <div class="bot">
 <input type="text" id="txt" placeholder="我來說兩句。。。" />
 <button type="button" id="btn">發(fā)送</button>
 </div>
 </div>
 <script src="jquery-1.12.4.js"></script>
 <script>
 $(function() {
 var colors = ["red", "green", "hotpink", "pink", "cyan", "yellowgreen", "purple", "deepskyblue"];
 $("#btn").on("click", function() {
  var randomColor = parseInt(Math.random() * colors.length);
  var randomY = parseInt(Math.random() * 400);
  $("<span></span>") //創(chuàng)建span
  .text($("#txt").val()) //設(shè)置內(nèi)容
  .css("color", colors[randomColor]) //設(shè)置字體顏色
  .css("left", "1400px") //設(shè)置left值
  .css("top", randomY) //設(shè)置top值
  .animate({
  left: -500
  }, 10000, "linear", function() {
  //到了終點(diǎn),需要?jiǎng)h除
  $(this).remove();
  }) //添加動(dòng)畫
  .appendTo(".top");

  $("#txt").val("");
 });
 });
 </script>
 </body>
</html>

CSS部分

* {
 margin: 0;
 padding: 0;
}

.box {
 width: 1600px;
 height: 757px;
}

.top {
 width: 100%;
 height: 660px;
 position: relative;
}

.bot {
 width: 100%;
 height: 97px;
 background-color: #666666;
 position: relative;
}

#txt {
 width: 300px;
 height: 30px;
 border-radius: 5px;
 position: absolute;
 left: 50%;
 margin-left: -150px;
 top: 50%;
 margin-top: -15px;
 border: none;
}

#btn {
 width: 60px;
 height: 30px;
 color: white;
 background-color: red;
 position: absolute;
 left: 955px;
 top: 34px;
 border: none;
}

span {
 position: absolute;
 color: #000;
 font-size: 50px;
 line-height: 1.5em;
 cursor: pointer;
 white-space: nowrap;
}

效果展示

以上就是jQuery實(shí)現(xiàn)彈幕效果的代碼,希望對您有幫助!

源碼下載:jQuery彈幕

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

定日县| 晴隆县| 秭归县| 兴安盟| 绥中县| 绥中县| 疏勒县| 肇州县| 奉节县| 吉水县| 玉田县| 乐陵市| 于田县| 湛江市| 张掖市| 崇义县| 临朐县| 都江堰市| 安平县| 五指山市| 鲜城| 肥西县| 台南市| 霍邱县| 江油市| 资兴市| 浦城县| 长垣县| 突泉县| 湾仔区| 秦皇岛市| 大同县| 汉川市| 江华| 美姑县| 平乐县| 山西省| 马尔康县| 大新县| 商都县| 冷水江市|