jq 弹幕

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script src="../jquery-3.4.1.min.js" type="text/javascript">			
		</script>
		<style type="text/css">
			.boxs{
				height: 500px;
				width: 1350px;
				background-color:#C8CBCA ;
				position: relative;
				overflow: hidden;
				/*left: 0px;
				top: 0px;*/
			}
			.boxx{
				height: 80px;
				width: 1350px;
				background-color: #636565;
				position: absolute;
				overflow: hidden;
				/*top: 300px;
				left: 0px;*/
			}
			
			.boxleft{
				float: left;
				font-size: 30px;
				margin-left: 50px;
				color: azure;
			}
			#nr{
				background-color: white;
				height: 25px;
				line-height: 25px;
			}
			.a{
				margin-left: 700px;
				display: inline-block;
			}
			.dong{
				position: absolute;
				line-height: 22px;
				display: inline-block;
			
			}
		</style>
		
	</head>
	<body>
		<div class="box">
			<div class="boxs">
				
			</div>
			<div class="boxx">
				<div class="a">
					<div class="boxleft">发送弹幕:</div>
					<div class="boxleft"><input type="" name="" id="nr" value="" /></div>
					<div class="boxleft"><button class="fs">发送</button></div>
				</div>
			</div>
		</div>
		<script type="text/javascript">
			
			$(function(){
				$('.fs').click(function(){
					//获取value值
					var $value=$('#nr').val();
					//创建
					var $p=$("<span class='dong'>"+$value+'</span>')					
					$p.appendTo($('.boxs'))					
					var $shuji=parseInt(Math.random()*500);
					//还可以定义随机函数加入随机色
					//用变调用量来这样每次出来的高度都不一样;
					$p.css({
						"width":'500px',
						'height':'22px',
						'left':'1400px',
						'fontSize':'30px',
						'top':$shuji,

					},20000).animate({
					'left':'-400px',
					},20000,function(){
						$(this).remove()
					})	
				})
			})
		</script>	
	</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Jason–json

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值