彈幕效果

<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<title>彈幕效果</title>
<script src="../../jquery-1.12.4.min.js" type="text/javascript" charset="utf-8"></script>
</head>
<style type="text/css">
html,
body {
margin: 0px;
padding: 0px;
width: 100%;
height: 100%;
font-family: "微軟雅黑";
font-size: 62.5%;
background: #ccc;
}

.boxDom {
width: 100%;
height: 100%;
position: relative;
overflow: hidden;
}

.idDom {
width: 100%;
height: 60px;
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;
}

.string {
width: 300px;
height: 40px;
position: absolute;
overflow: hidden;
color: #000;
font-size: 4em;
line-height: 1.5em;
cursor: pointer;
white-space: nowrap;
}
</style>

<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">發射</button>
</div>
</div>
</div>
<script type="text/javascript">
$(function() {
var pageW = parseInt($(document).width());
var pageH = parseInt($(document).height());
var boxDom = $("#boxDom");
var btnDom = $("#btn");
var Top, Right;
var width;
width = pageW;
var colorArr = ["#cfaf12", "#12af01", "#981234", "#adefsa", "#db6be4", "#f5264c", "#d34a74"];
btnDom.bind("click", auto);
document.onkeydown = function(e) {
if(e.keyCode == 13) {
auto();
}
}

function auto() {
var creSpan = $("<span class='string'></span>");
var text = $("#text").val();
creSpan.text(text);
$("#text").val("");
Top = parseInt(pageH * (Math.random()));
var num = parseInt(colorArr.length * (Math.random()));
if(Top > pageH - 90) {
Top = pageH - 90;
}
creSpan.css({
"top": Top,
"right": -300,
"color": getRandomColor()
});
boxDom.append(creSpan);
var spanDom = $("#boxDom>span:last-child");
spanDom.stop().animate({
"right": pageW + 300
}, 10000, "linear", function() {
$(this).remove();
});
}

function getRandomColor() {
return '#' + (function(h) {
console.log(h)
return new Array(7 - h.length).join("0") + h
})((Math.random() * 0x1000000 << 0).toString(16));
}
});
</script>
</body>

</html>

轉載于:https://www.cnblogs.com/icey618/p/7686716.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/280128.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/280128.shtml
英文地址,請注明出處:http://en.pswp.cn/news/280128.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

基于.NetCore開發博客項目 StarBlog - (21) 開始開發RESTFul接口

1前言最近電腦壞了&#xff0c;開源項目的進度也受到一些影響這篇醞釀很久了&#xff0c;作為本系列第二部分&#xff08;API接口開發&#xff09;的第一篇&#xff0c;得想一個好的開頭&#xff0c;想著想著就鴿了好久&#xff0c;索性不扯那么多了&#xff0c;直接開寫吧~2關…

03 Oracle分區表

Oracle分區表 先說句題外話… 歡迎成都天府軟件園的小伙伴來面基交流經驗~ 一&#xff1a;什么是分區&#xff08;Partition&#xff09;&#xff1f; 分區是將一個表或索引物理地分解為多個更小、更可管理的部分。 分區對應用透明&#xff0c;即對訪問數據庫的應用而言&…

windows獲取本地時間_如何在Windows 8中重新獲得本地登錄

windows獲取本地時間By default a fresh Windows 8 installation prompts you to create a synchronized cloud-enabled login. While there are distinct perks to Microsoft’s live login system, sometimes you just want to keep things simple and local. Read on as we …

如何解決高并發,秒殺問題

相信不少人會被這個問題困擾&#xff0c;分享大家一篇這樣的文章&#xff0c;希望能夠幫到你&#xff01; 一、秒殺業務為什么難做&#xff1f;1&#xff09;im系統&#xff0c;例如qq或者微博&#xff0c;每個人都讀自己的數據&#xff08;好友列表、群列表、個人信息&#xf…

Spring原理之代理與動態代理模式總結(四)

2019獨角獸企業重金招聘Python工程師標準>>> 代理模式 1&#xff0c;什么是代理模式&#xff1f; 代理模式的作用是&#xff1a;為其他對象提供一種代理以控制對這個對象的訪問。2&#xff0c;代理模式有什么好處&#xff1f; 在某些情況下&#xff0c;一個客戶不…

可執行文件添加快捷方式_如何停止Windows向快捷方式文件名添加“-快捷方式”...

可執行文件添加快捷方式When you make a new shortcut in Windows, it automatically adds “- Shortcut” to the end of the shortcut’s file name. This doesn’t seem like a big deal, but they can be bothersome. Sure, you can remove the text yourself when you cre…

Red hat6.4重新安裝yum

今天在Red Hat上安裝軟件時&#xff0c;發現需要依賴軟件&#xff0c;然而在用yum指令時&#xff0c;出現了下面的錯誤&#xff1a; This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. 出現這個問題的原因是&…

使用 BenchmarkDotNet 比較指定容量的 List 的性能

我們之前提到 List 是 .NET 中常用的數據結構&#xff0c;其在存儲大量數據時&#xff0c;如果能夠指定它的初始化容量&#xff0c;就會有性能提升。這個優化的方法并不是很明顯&#xff0c;因此本文將使用 BenchmarkDotNet 庫&#xff0c;通過定量對比的方式來證明這一點。實驗…

看明星合影爭C位,學PPT中C位排版法

在娛樂圈里&#xff0c;C位是大咖位&#xff0c;是對藝人實力的最好證明&#xff0c;藝人們自然會想著去力爭C位&#xff0c;正所謂“不想當將軍的兵不是好兵&#xff0c;不想站C位的明星不是好明星”。那么&#xff0c;C位是什么意思&#xff1f;C位&#xff0c;網絡流行語&am…

javafx由淺到深的 認識(一)

javafx是一款比較新興的語言框架,隨著javafx越來越實用,估計許多程序員也會慢慢接觸它,故我在這里對它由淺到深進行介紹一下. 首先,要了解javafx,就應該先知道.xml文件的布局軟件,以往java都是通過敲代碼來進行布局的,但javafx有力新的突破,它實現了拖動方式,目前我使用的輔助軟…

linux用戶的根目錄_為什么Linux允許用戶刪除根目錄?

linux用戶的根目錄Most of the time, none of us willingly performs an action that will literally break our operating systems and force us to reinstall them. But what if such an action could easily occur even by accident on the user’s part? Today’s SuperUs…

純css實現叉號

HMTL部分 <a href"#" class"close"></a> CSS部分 .close {position: absolute;right: 32px;top: 32px;width: 32px;height: 32px; } .close:before, .close:after {position: absolute;left: 15px;content: ;height: 33px;width: 2px;backgro…

微軟跨平臺maui開發chatgpt客戶端

image什么是maui.NET 多平臺應用 UI (.NET MAUI) 是一個跨平臺框架&#xff0c;用于使用 C# 和 XAML 創建本機移動(ios,andriod)和桌面(windows,mac)應用。imagechagpt最近這玩意很火&#xff0c;由于網頁版本限制了ip&#xff0c;還得必須開代理&#xff0c; 用起來比較麻煩&a…

在Xshell 6開NumLock時按小鍵盤上的數字鍵并不能輸入數字

小鍵盤問題 在Xshell 6上用vi的時候&#xff0c;開NumLock時按小鍵盤上的數字鍵并不能輸入數字&#xff0c;而是出現一個字母然后換行&#xff08;實際上是命令模式上對應上下左右的鍵&#xff09;。解決方法 選項Terminal->Features里&#xff0c;找到Disable application …

WebP 在減少圖片體積和流量上的效果如何?—— WebP 技術實踐分享

作者 | Jackson編輯 | 尾尾 不論是 PC 還是移動端&#xff0c;圖片一直占據著頁面流量的大頭&#xff0c;在圖片的大小和質量之間如何權衡&#xff0c;成為了長期困擾開發者們的問題。而 WebP 技術的出現&#xff0c;為解決該問題提供了好的方案。本文將為大家詳細介紹 WebP 技…

chrome 固定縮放比例_您如何調整Google Chrome瀏覽器的用戶界面縮放比例?

chrome 固定縮放比例Everything can be going along nicely until a program gets a new update that suddenly turns everything into a visual mess, like scaling up the UI, for example. Is there a simple solution? Today’s SuperUser Q&A post has some helpful …

樹莓派 Raspberry Pi 更換國內源

http://www.shumeipaiba.com/wanpai/jiaocheng/16.html轉載于:https://www.cnblogs.com/Baronboy/p/9185849.html

優雅告別 2022 年,2023 年主題:敢想,就敢做!

自從工作之后&#xff0c;每年春節我都會花一天時間&#xff0c;一個人待在一個小房間&#xff0c;思考自己今年做了什么具備階段性成果的事情。然后&#xff0c;寫下明年需要執行的計劃。會寫在一個 XMind 文件里&#xff0c;記錄每一年將要執行的計劃&#xff0c;且未完成的計…

純js上傳文件 很好用

<!DOCTYPE html> <html> <head> <meta charset"utf-8"> <meta name"viewport" content"widthdevice-width, initial-scale1.0"> <title>參數設置</title> <meta name"keywords&q…

買臺電腦,不行!去旅游一下,不行!論程序員怎么實現財務自由!

“最近讀了一本不是編程的程序員技能書《軟技能-代碼之外的生存指南》&#xff0c;全書分為 7 個篇章&#xff0c;分別是職業、自我營銷、學習、生產力、理財、健身和精神。在讀完職業、自我營銷和理財這三個篇章后&#xff0c;讓我感觸很深&#xff0c;也讓我很意外。本來以為…