jQuery實(shí)現(xiàn)的彈幕效果完整實(shí)例
本文實(shí)例講述了jQuery實(shí)現(xiàn)的彈幕效果。分享給大家供大家參考,具體如下:
看視頻的時(shí)候老是會(huì)出現(xiàn)一些彈幕,對(duì)于這個(gè)看著很高大上的特效,其實(shí)也不難實(shí)現(xiàn)。
先來看看運(yùn)行效果:

下面將整個(gè)代碼顯示出來:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>chabaoo.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擴(kuò)展技巧總結(jié)》、《jQuery常見經(jīng)典特效匯總》、《jQuery動(dòng)畫與特效用法總結(jié)》、《jquery選擇器用法總結(jié)》及《jQuery常用插件及用法總結(jié)》
希望本文所述對(duì)大家jQuery程序設(shè)計(jì)有所幫助。
相關(guān)文章
jquery捕捉回車鍵及獲取checkbox值與異步請(qǐng)求的方法
這篇文章主要介紹了jquery捕捉回車鍵及獲取checkbox值與異步請(qǐng)求的方法,實(shí)例分析了jQuery針對(duì)回車鍵的捕捉,checkbox值的獲取以及異步請(qǐng)求的響應(yīng)等相關(guān)技巧,需要的朋友可以參考下2015-12-12
EasyUI學(xué)習(xí)之Combobox級(jí)聯(lián)下拉列表(2)
這篇文章主要為大家詳細(xì)介紹了EasyUI學(xué)習(xí)之Combobox級(jí)聯(lián)下拉列表的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-12-12
jquery插件tytabs.jquery.min.js實(shí)現(xiàn)漸變TAB選項(xiàng)卡效果
這篇文章主要介紹了jquery插件tytabs.jquery.min.js實(shí)現(xiàn)漸變TAB選項(xiàng)卡效果,實(shí)例分析了tytabs.jquery.min.js插件實(shí)現(xiàn)tab選項(xiàng)卡切換效果的使用技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-08-08
深入學(xué)習(xí)jQuery Validate表單驗(yàn)證
這篇文章主要針對(duì)jQuery Validate表單驗(yàn)證為大家進(jìn)行詳細(xì)介紹,如何在class屬性里面并定義錯(cuò)誤信息的提示,感興趣的小伙伴們可以參考一下2016-01-01
jQuery插件zTree實(shí)現(xiàn)刪除樹節(jié)點(diǎn)的方法示例
這篇文章主要介紹了jQuery插件zTree實(shí)現(xiàn)刪除樹節(jié)點(diǎn)的方法,結(jié)合實(shí)例形式分析了jQuery樹插件zTree針對(duì)節(jié)點(diǎn)的遍歷與刪除操作相關(guān)技巧,需要的朋友可以參考下2017-03-03

