jQuery實現(xiàn)的彈幕效果完整實例
本文實例講述了jQuery實現(xiàn)的彈幕效果。分享給大家供大家參考,具體如下:
看視頻的時候老是會出現(xiàn)一些彈幕,對于這個看著很高大上的特效,其實也不難實現(xiàn)。
先來看看運行效果:
下面將整個代碼顯示出來:
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>www.dbjr.com.cn彈幕</title> <style type="text/css"> html,body{ background:#efefef; height:100%; } .danmu{ width: 100px; height:30px; line-height: 28px; background: green; border-radius: 5px; border:1px solid #fff; color: #fff; outline: none; } div.mask{ position:fixed; width:100%; height:100%; background:rgba(0,0,0,0.8); opacity:0.5; top:0px; left:0px; } div.bottom{ width:100%; height:77px; background:linear-gradient(#ccc,#4a4a4a); position:fixed; bottom:0px; left:0px; text-align:center; line-height:77px; } div.bottom input.content{ width:50%; min-width: 200px; height:37px; border:none; border-radius:10px 0px 0px 10px; font-size:16px; padding:0 10px; outline:none; } div.bottom a.send{ background-color:green; color:#fff; display:inline-block; width:100px; height:38px; 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:30px; height:30px; border-radius:50%; background-color:green; color:#fff; position:fixed; top:20px; right:20px; text-align:center; line-height:30px; font-size:20px; 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; } </style> </head> <body> <button class="danmu">彈幕技術(shù)</button> <div class="mask"> <a href="#" rel="external nofollow" rel="external nofollow" class="button">X</a> </div> <!-- 底部發(fā)言框前端 --> <div class="bottom"> <input class="content"></input> <a href="#" rel="external nofollow" rel="external nofollow" class="send">發(fā)表言論</a> </div> <script type="text/javascript" src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script> <script> $("a.send").click(function(){ var val=$(".content").val(); var content=$("<div class='text'>"+val+"</div>"); var top=Math.random()*$(document.body).height()+40+"px"; content.css("top",top); $(".mask").append(content); content.animate({right:$(document.body).width()+100},8000,function(){ $(this).remove(); }) }); $('.button').click(function(){ $('div.mask').fadeOut(500); }); $(".danmu").click(function(){ $('div.mask').fadeIn(500); }); </script> </body> </html>
更多關(guān)于jQuery相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《jQuery切換特效與技巧總結(jié)》、《jQuery拖拽特效與技巧總結(jié)》、《jQuery擴展技巧總結(jié)》、《jQuery常見經(jīng)典特效匯總》、《jQuery動畫與特效用法總結(jié)》、《jquery選擇器用法總結(jié)》及《jQuery常用插件及用法總結(jié)》
希望本文所述對大家jQuery程序設(shè)計有所幫助。
相關(guān)文章
jquery捕捉回車鍵及獲取checkbox值與異步請求的方法
這篇文章主要介紹了jquery捕捉回車鍵及獲取checkbox值與異步請求的方法,實例分析了jQuery針對回車鍵的捕捉,checkbox值的獲取以及異步請求的響應(yīng)等相關(guān)技巧,需要的朋友可以參考下2015-12-12EasyUI學習之Combobox級聯(lián)下拉列表(2)
這篇文章主要為大家詳細介紹了EasyUI學習之Combobox級聯(lián)下拉列表的相關(guān)資料,具有一定的參考價值,感興趣的小伙伴們可以參考一下2016-12-12jquery插件tytabs.jquery.min.js實現(xiàn)漸變TAB選項卡效果
這篇文章主要介紹了jquery插件tytabs.jquery.min.js實現(xiàn)漸變TAB選項卡效果,實例分析了tytabs.jquery.min.js插件實現(xiàn)tab選項卡切換效果的使用技巧,具有一定參考借鑒價值,需要的朋友可以參考下2015-08-08jQuery插件zTree實現(xiàn)刪除樹節(jié)點的方法示例
這篇文章主要介紹了jQuery插件zTree實現(xiàn)刪除樹節(jié)點的方法,結(jié)合實例形式分析了jQuery樹插件zTree針對節(jié)點的遍歷與刪除操作相關(guān)技巧,需要的朋友可以參考下2017-03-03