jQuery實(shí)現(xiàn)彈幕效果案例
本文實(shí)例為大家分享了jQuery實(shí)現(xiàn)彈幕效果的具體代碼,供大家參考,具體內(nèi)容如下
效果:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>吐槽彈幕</title> <script type="text/javascript" src="jquery-3.2.1.min.js" ></script> <style> html, body { margin: 0px; padding: 0px; width: 100%; height: 100%; font-family: "微軟雅黑"; font-size: 62.5%; } .boxDom { width: 100%; height: 100%; position: relative; overflow: hidden; } .idDom { width: 100%; height: 100px; background: #666; position: fixed; bottom: 0px; } .content { display: inline-block; width: 430px; height: 40px; position: absolute; left: 0px; right: 0px; top: 0px; bottom: 0px; margin: auto; } .title { display: inline; font-size: 4em; vertical-align: bottom; color: #fff; } .text { border: none; width: 300px; height: 30px; border-radius: 5px; font-size: 2.4em; } .btn { width: 60px; height: 30px; background: #f90000; border: none; color: #fff; font-size: 2.4em; } span { width: 300px; height: 40px; position: absolute; overflow: hidden; color: #000; font-size: 4em; line-height: 1.5em; cursor: pointer; white-space: nowrap; } </style> </head> <body> <div class="boxDom" id="boxDom"> <div class="idDom" id="idDom"> <div class="content"> <p class="title">吐槽:</p> <input type="text" class="text" id="text"/> <button type="button" class="btn" id="btn">發(fā)射</button> </div> </div> </div> <script> $(function () { //注冊(cè)事件 各個(gè)顏色的彈幕字體 var colors = ["red", "green", "hotpink", "pink", "cyan", "yellowgreen", "purple", "deepskyblue"]; $("#btn").click(function () { var randomColor = parseInt(Math.random() * colors.length); var randomY = parseInt(Math.random() * 400); $("<span></span>")//創(chuàng)建span .text($("#text").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("#boxDom"); $("#text").val(""); }); $("#text").keyup(function (e) { if (e.keyCode == 13) { $("#btn").click(); } }); }); </script> </body> </html>
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- js實(shí)現(xiàn)七夕表白彈幕效果 jQuery實(shí)現(xiàn)彈幕技術(shù)
- jQuery實(shí)現(xiàn)簡(jiǎn)單彈幕制作
- jQuery實(shí)現(xiàn)彈幕特效
- jquery實(shí)現(xiàn)直播彈幕效果
- jQuery實(shí)現(xiàn)簡(jiǎn)單彈幕效果
- 簡(jiǎn)單實(shí)現(xiàn)jQuery彈幕效果
- 基于jQuery實(shí)現(xiàn)彈幕APP
- 基于jquery實(shí)現(xiàn)彈幕效果
- 又一枚精彩的彈幕效果jQuery實(shí)現(xiàn)
- 終于實(shí)現(xiàn)了!精彩的jquery彈幕效果
相關(guān)文章
jQuery.event兼容各瀏覽器的event詳細(xì)解析
jQuery在遵循W3C規(guī)范的情況下,對(duì)事件的常用屬性進(jìn)行了封裝,使得事件處理在各大瀏覽器下都可以正常的運(yùn)行而不需要進(jìn)行瀏覽器類型判斷2013-12-12jQuery實(shí)現(xiàn)簡(jiǎn)單下拉導(dǎo)航效果
這篇文章主要介紹了jQuery實(shí)現(xiàn)簡(jiǎn)單下拉導(dǎo)航效果,通過簡(jiǎn)單的元素遍歷與樣式替換實(shí)現(xiàn)下拉導(dǎo)航的功能,非常具有實(shí)用價(jià)值,需要的朋友可以參考下2015-09-09兩個(gè)多選select(multiple左右)添加、刪除選項(xiàng)和取值實(shí)例
這篇文章主要介紹了兩個(gè)多選select(multiple左右)添加、刪除選項(xiàng)和取值實(shí)例,使用jquery實(shí)現(xiàn),需要的朋友可以參考下2014-05-05jQuery自動(dòng)完成插件completer附源碼下載
這篇文章主要介紹了jQuery自動(dòng)完成插件completer的相關(guān)資料,需要的朋友可以參考下2016-01-01jquery實(shí)現(xiàn)ajax提交表單信息的簡(jiǎn)單方法(推薦)
下面小編就為大家?guī)?lái)一篇jquery實(shí)現(xiàn)ajax提交表單信息的簡(jiǎn)單方法(推薦)。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來(lái)看看吧2016-08-08jquery.serialize() 函數(shù)語(yǔ)法及簡(jiǎn)單實(shí)例
下面小編就為大家?guī)?lái)一篇jquery.serialize() 函數(shù)語(yǔ)法及簡(jiǎn)單實(shí)例。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來(lái)看看吧2016-07-07JQuery統(tǒng)計(jì)input和textarea文字輸入數(shù)量(代碼分享)
本文主要介紹了jQuery實(shí)現(xiàn)統(tǒng)計(jì)輸入文字個(gè)數(shù)的方法,具有一定的參考價(jià)值,需要的朋友一起來(lái)看下吧2016-12-12Jquery結(jié)合HTML5實(shí)現(xiàn)文件上傳
本文給大家介紹的是利用Jquery使用HTML5的FormData屬性實(shí)現(xiàn)對(duì)文件的上傳的方法和實(shí)例,非常的實(shí)用,有需要的小伙伴可以參考下。2015-06-06JQuery.uploadify 上傳文件插件的使用詳解 for ASP.NET
今天下午整理文件上傳的例子,感覺收集到的例子都很不人性話,后來(lái)找到一個(gè)還可以的,本來(lái)想改成類似于騰訊QQ相冊(cè)那種方式,仔細(xì)看了一下是Flash的, 而且那個(gè)極速上傳插件也不知道用什么做的?問了一下,說是什么cgi. 搞得一頭霧水2010-01-01