In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Today, the editor will share with you the relevant knowledge points about how to realize the video on-screen comment in the front end of web. The content is detailed and the logic is clear. I believe most people still know too much about this, so share this article for your reference. I hope you can get something after reading this article. Let's learn about it.
Code presentation
1 > html code display
Close the barrage and turn on mute.
2 > css code display
* {padding: 0; margin: 0;} input {outline: none;}. Barrage {position: relative; width: 100%; height:250px;} # myvideo {position: absolute; / * width: 100%; height:300px; * / top:-50px; left: 0; z-index:-1;} .barrage .screen {position: absolute; top: 0px; right: 0px; width: 100% Height: 300px;} .barrage .screen .content {position: relative; width: 100%; height: 250px; background: # 000; opacity:0.5; / * filter: alpha (opacity=100); * / / * for browsers above ie8 or earlier * * / background-color: transparent; z-index: 1; .barrage .screen .content div {position: absolute; font-size: 20px; font-weight: bold White-space: nowrap; line-height: 40px; z-index: 40;} .barrage .send {position: absolute; bottom: 0px; width: 100%; height: 55px; line-height: 55px; z-index: 1; / * background: # 000 z-index: rgba; text-align: center; / * display: none;*/}. Barrage:hover .send {display: block } .barrage .send .s _ text {width: 60%; height:35px; line-height:35px; font-size: 16px; font-family: "Microsoft Acer"; border-radius:20px; opacity: 0.8;} .barrage .send .s _ btn {width: 105px; height:35px; line-height:35px; background: # 22B14C; color: # fff; border-radius: 10px; opacity: 0.8 }. Barrage_close,#muted {width: 80px; height: 30px; line-height: 30px; border-radius: 10px; text-align: center; color: # 22B14C; background:#fff; cursor: pointer; opacity: 0.8;} # muted {background:yellow;}. Barrage_close1 {color: # fff; background:#fff;} / * css animation * / .content div {animation:Text 15s infinite normal } @ keyframes Text {0% {left:100%;} 20% {left:75%;} 80% {left:0%;} 100% {left:-30%;}}
3 > js code display
(function () {$(".barrage _ close") .click (function () {$(".content div"). Remove ();}); init_barrage ();}); / / put the contents of the barrage into an array and store them in var arr= []; var h=arr.push (); / / listen to send, press enter to send document.documnkeydnewwn = function (event) {var e = event | | window.event If (e & & e.keyCode==13) {/ / console.log (11111); $(".send .s _ btn") .click ();}}; / / submit comments $(".send .s _ btn") .click (function () {var text = $(".s _ text") .val () If (text = "") {alert ('your content is empty, please fill in the comment before sending'); return false;} var _ lable = $("" + text + "); $(" .content "). Append (_ lable.show ()); init_barrage (); $(" .s _ text "). Val (");}) / / initialize the on-screen comment technology function init_barrage () {var _ top = 0; $(".content div") .show () .each (function () {var _ left = $(".barrage") .width (); / / the maximum width of the browser view (also the height of the browser) as the value console.log (_ left) for locating the left; var _ height = $(".barrage"). Height () / / the maximum height of the video window console.log (_ height); _ top + = 35; if (_ top > = (_ height-150)) {_ top = 0;} $(this). Css ({left: _ left, top: _ top, color: getColor ()}); / / timed pop-up text / / var time = 10000 / / if ($(this). Index ()% 2 = 0) {/ / time = 15000; / /} / / $(this) .animate ({left: "-" + _ left + "px"}, time, function () {/ / $(this). Remove (); /});}) } / / get random color function getColor () {return'#'+ (function (h) {return new Array (7-h.length) .join ("0") + h}) ((Math.random () * 0x1000000)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.