欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

javascript實現(xiàn)視頻彈幕效果(兩個版本)

本文實例為大家分享了javascript實現(xiàn)視頻彈幕效果的具體代碼,供大家參考,具體內(nèi)容如下

創(chuàng)新互聯(lián)建站2013年開創(chuàng)至今,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項目成都做網(wǎng)站、成都網(wǎng)站建設(shè)網(wǎng)站策劃,項目實施與項目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元淮濱做網(wǎng)站,已為上家服務(wù),為淮濱各地企業(yè)和個人服務(wù),聯(lián)系電話:18982081108

基礎(chǔ)版本

<!DOCTYPE html>
<html lang="en">

<head>
 <meta charset="utf-8">
 <style>
 * {
 margin: 0;
 padding: 0;
 }

 .dm {
 width: 800px;
 height: 600px;
 background-color: blue;
 margin: 0 auto;
 }

 .box {
 height: 500px;
 background-color: #000;
 position: relative;
 overflow: hidden;
 }

 video {
 width: 100%;
 height: 100%;
 }

 .info {
 text-align: center;
 margin-top: 20px;
 }

 input[type=text] {
 width: 500px;
 height: 50px;
 }

 input[type=button] {
 height: 50px;
 width: 100px;

 }

 span {
 position: absolute;
 /* 文本強制不換行 */
 white-space: nowrap;
 font: bold 18px '微軟雅黑';
 }
 </style>

</head>

<body>
 <div class="dm">
 <div class="box">
 <video src="m.mp4" controls></video>
 </div>
 <div class="info">
 <input type="text" maxlength="30" id="txt">
 <input type="button" value="發(fā)射" id="emit">
 </div>
 </div>
 <script src="jquery-1.12.4.js"></script>
 <script>
 // 0. 用一個數(shù)組保存一組顏色值
 var colors = ['red', 'green', 'yellow', '#fff', 'pink', 'blue'];
 // 1. 給發(fā)射按鈕注冊點擊事件
 $('#emit').click(function () {
 // 2. 獲取文本框的內(nèi)容
 var v = $('#txt').val();
 // 3. 創(chuàng)建span標簽,并設(shè)置內(nèi)容,設(shè)置樣式,最后追加到類名為box的div中
 var $span = $('<span></span>');
 $span.text(v)
 .css({
  left: $('.box').width(),
  top: parseInt(Math.random() * $('.box').height()),
  color: colors[parseInt(Math.random() * colors.length)]
 }).appendTo('.box');
 // 4. 讓當前的span產(chǎn)生動畫 left 為-span的寬度
 $span.animate({
 left: -1 * $span.width()
 }, 6000, 'linear', function () {
 // 當動畫結(jié)束后,刪除該元素
 $span.remove();
 })
 });
 </script>

</body>

</html>

加強版本

<!DOCTYPE html>
<html lang="en">

<head>
 <meta charset="utf-8">
 <style>
 * {
 margin: 0;
 padding: 0;
 }

 .dm {
 width: 800px;
 height: 600px;
 background-color: blue;
 margin: 0 auto;
 }

 .box {
 height: 500px;
 background-color: #000;
 position: relative;
 overflow: hidden;
 }

 video {
 width: 100%;
 height: 100%;
 }

 .info {
 text-align: center;
 margin-top: 20px;
 }

 input[type=text] {
 width: 500px;
 height: 50px;
 }

 input[type=button] {
 height: 50px;
 width: 100px;

 }

 span {
 position: absolute;
 /* 文本強制不換行 */
 white-space: nowrap;
 font: bold 18px '微軟雅黑';
 }
 </style>

</head>

<body>
 <div class="dm">
 <div class="box">
 <!-- controls 如果出現(xiàn)該屬性,則向用戶顯示控件,比如播放按鈕。 -->
 <video src="m.mp4" controls></video>
 </div>
 <div class="info">
 <input type="radio" value="" id="ban" name="1">精簡</input>
 <input type="radio" value="" id="vip" name="1">VIP尊享</input>
 <input type="text" maxlength="30" id="txt">
 <input type="button" value="發(fā)射" id="emit">
 </div>
 </div>
 <script src="jquery-1.12.4.js"></script>
 <script>
 // 0. 用一個數(shù)組保存一組顏色值
 var colors = ['red', 'green', 'yellow', '#fff', 'pink', 'blue'];

 //定義一個變量,定義其他樣式的
 b = 0
 $('#ban').click(function () {
 b = 1;
 });
 $('#vip').click(function () {
 b = 2;
 });




 // 1. 給發(fā)射按鈕注冊點擊事件
 $('#emit').click(function () {
 // 2. 獲取文本框的內(nèi)容
 var v = $('#txt').val();
 // 3. 創(chuàng)建span標簽,并設(shè)置內(nèi)容,設(shè)置樣式,最后追加到類名為box的div中
 var $span = $('<span></span>');

 //定義CSS樣式,讓它是一個數(shù)組形式表現(xiàn)
 css = [{
  "left": $('.box').width(),
  "top": parseInt(Math.random() * $('.box').height()),
  "color": colors[parseInt(Math.random() * colors.length)]
 },
 {
  "left": $('.box').width(),
  "top": parseInt(Math.random() * ($('.box').height() / 2)),
  "color": colors[parseInt(Math.random() * colors.length)]
 },
 {
  "left": $('.box').width(),
  "top": parseInt(Math.random() * $('.box').height()),
  "color": "yellow",
  "fontSize": 50,
  "fontFamily": "楷體"
 }
 ]
 //看看能不能打印出數(shù)組中的東西
 // console.log(abc[1])

 $span.text(v)
 .css(css[b])
 .appendTo('.box');

 // 4. 讓當前的span產(chǎn)生動畫 left 為-span的寬度

 //打印出文本長度
 // console.log(v.length)

 $span.animate({
  left: -1 * $span.width()
 }, (30 - v.length) * 333, 'linear',
 function () {
  // 當動畫結(jié)束后,刪除該元素
  $span.remove();
 })
 });
 </script>

</body>

</html>

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持創(chuàng)新互聯(lián)。

當前題目:javascript實現(xiàn)視頻彈幕效果(兩個版本)
標題URL:http://aaarwkj.com/article34/pcddpe.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信公眾號網(wǎng)站維護、網(wǎng)站制作、云服務(wù)器、面包屑導(dǎo)航、網(wǎng)頁設(shè)計公司

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站建設(shè)
国产精品精品久久久久久| 亚洲理论在线观看电影| 中文字幕乱码一区二区欧美| 亚洲精品a在线观看av| 国产激情盗摄一区二区三区| 青青青在线视频观看华人| 禁止18观看视频软件| 亚洲欧洲日本一区精品| 国产精品精品久久久久久| 99久久久精品国产免费| 高清免费欧美大片在线观看| 亚洲香蕉av一区二区蜜桃| 成年人免费观看黄色片| 九九视频免费观看5| 国产成十人十综合十亚洲| 风间由美亚洲一区二区三区| 6080yy精品一区二区三区| 日韩传媒在线观看视频| 黄片免费在线播放欧美| 高清欧美一区二区三区日本| 日本一区二区不卡视频在线播放| 蜜桃av网站免费观看| 麻豆国产免费av在线| 亚州无吗一区二区三区| 91国产熟女自拍视频| 亚洲日本一区二区三区电影| 18禁的视频在线观看| 欧美亚洲午夜精品久久久| 妞妞婷婷基地五月天| 日本一区二区三区免费不卡视频 | 久久99精品人妻一区二区三区| 九色综合一区二区三区| 日本在线一区二区视频麻豆| 日本特黄特黄录像在线| 黑丝美女被内射视频免费观看| 五月婷婷六月丁香伊人网| 伊人亚洲中文一区二区| 欧美国产综合欧美一区二区三区 | 国产精品亚洲国产精品| 18岁下禁止看的视频| 男女真人啪啪视频免费|