该文章短小精悍
问?视频全屏后如何加弹幕
答:了解一下 screenfull; pointer-events: none;
(若是你没有领会个人意思,我能够手摸手带你撸一遍)css
WEY?html
4.错在了哪里git
这个问题若是思路错了就是个死胡同。因此我在找问题的时候趟了不少坑。思路错在我不该该使用视频的全屏,敲黑板!划重点啦!不要使用视频的全屏!(解决了问题的时候才幡然醒悟),而后发现了个贼有意思的东西。[screenfull][3]。不知道B站他们怎么玩的,可是我用这个实现了。这个东西作了一个事情让你浏览器的DOM铺满全屏。欧?~~~
5 实现它
DOMgithub
<div class='player' id='vb'> <video id='vd' playsinline webkit-playsinline="true" controls style='object-fit: contain;'> <source src="http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4" type="video/mp4" /> </video> <div class='video-status' id='log'> <img src="http://wx4.sinaimg.cn/large/006ARE9vgy1fs9w9ukwjhj30g40afaap.jpg" alt=""> </div> </div>
Scriptweb
<script src="https://cdn.bootcss.com/screenfull.js/4.1.0/screenfull.js"></script> <script> const log = document.getElementById('log') const videoBox = document.getElementById('vb') log.onclick = _=> { const fullFlag = videoBox.className.indexOf('full-screen') if (fullFlag === -1) { videoBox.setAttribute('class', 'player full-screen') } else { videoBox.setAttribute('class', 'player') } screenfull.toggle() } </script>
CSS浏览器
<style> /* reset */ html,body,h1,h2,h3,h4,h5,h6,div,dl,dt,dd,ul,ol,li,p,blockquote,pre,hr,figure,table,caption,th,td,form,fieldset,legend,input,button,textarea,menu{margin:0;padding:0;} header,footer,section,article,aside,nav,hgroup,address,figure,figcaption,menu,details{display:block;} table{border-collapse:collapse;border-spacing:0;} caption,th{text-align:left;font-weight:normal;} html,body,fieldset,img,iframe,abbr{border:0;} i,cite,em,var,address,dfn{font-style:normal;} [hidefocus],summary{outline:0;} li{list-style:none;} h1,h2,h3,h4,h5,h6,small{font-size:100%;} sup,sub{font-size:83%;} pre,code,kbd,samp{font-family:inherit;} q:before,q:after{content:none;} textarea{overflow:auto;resize:none;} label,summary{cursor:default;} a,button{cursor:pointer;} h1,h2,h3,h4,h5,h6,em,strong,b{font-weight:bold;} del,ins,u,s,a,a:hover{text-decoration:none;} body,textarea,input,button,select,keygen,legend{font:12px/1.14 arial,\5b8b\4f53;color:#333;outline:0;} body{background:#fff;} a,a:hover{color:#333;} .player { width: 800px; height: auto; margin: 0 auto; position: relative; background-color: black; } .player video{ width: 100%; height: 100%; } .video-status { position: absolute; right: 100px; top: 40px; } .video-status img { width: 100px; } .full-screen { position: fixed; width: 100%; height: 100%; } </style>
去个人代码里找你须要的东西吧。ide
6.pointer-events是啥?弹幕呢?spa
pointer-events 是一个CSS属性作点透的时候用的,若是你有一个弹幕层在Video上边你会须要到她的。弹幕呢,没有。好多人都已经实现了好很差,这个你仍是去问问[百度][5]或者[必应][6]吧。
GitHub 地址 https://github.com/Gao-Fan/vi...3d