帮助中心
获取牛币
联系我们
关于我们
版权声明
素材牛首页
微博登录
QQ登录
微信扫码登录
注册
登录
新浪微博
QQ登陆
微信登录
热门搜索:
小程序
支付
Java
后台模板
上传
商城模板
jQuery
手机
Thinkphp
微信
Vue.js
首 页
网页特效
整站源码
PHP实例
网站模版
工具箱
常用代码
论坛
游戏源码
资源分享
当前位置:
首页
»
精选常用代码
» 简单的发弹幕效果
简单的发弹幕效果
浏览:962次
-
评论:0次
-
发布时间:2018-01-31
Html
Css
Js
弹幕列表
空巢老人:
这是什么啊
发送弹幕
.context { width:800px; height:300px; border:1px solid #ccc; display:-webkit-box; -webkit-box-orient:horizontal; position:relative; } .dm-y-list { width:200px; height:300px; border-left:1px solid #ccc; position:relative; } .send-dm { width:200px; height:34px; border:1px solid #ccc; position:absolute; bottom:0; left:0; } .dm-list-top { width:100%; height:30px; font-size:16px; text-align:center; line-height:30px; border-bottom:1px solid #ccc; } .send-dm input { width:116px; height:30px; float:left; border:1px solid #ccc; } .send-dm button { width:80px; height:34px; float:left; background:#0188FB; border:none; color:white; } .dm-list-cont { width:200px; height:236px; overflow:auto; } .dm-font-y { width:100%; height:auto; font-size:12px; margin-top:10px; white-space:pre-wrap; } .dm-font-x { width:auto; overflow:hidden; height:30px; color:white; line-height:30px; text-align:center; margin-left:600px; position:absolute; opacity:1; } .bg { width:600px; height:300px; z-index:999; background:rgba(0,0,0,.1); position:absolute; top:0; left:0; overflow:hidden; }
$('.sendBtn').on('click', function() { var dmtxt = $(this).prev().val(); if (dmtxt != '') { var arr = ['blue', 'red', 'green', 'skyblue', 'orange']; var bgHeight = $('.bg').height(); var j = Math.floor(Math.random() * bgHeight); if (j < 0) { j = 0 } else if (j > 240) { j = 270 } var i = Math.floor(Math.random() * arr.length); var div = "
空巢老人:
" + dmtxt + "
"; var div2 = "
" + dmtxt + "
"; $('.bg').append(div2); var x = $('.bg').children('div:last').offset(); $('.bg').children('div:last').animate({ marginLeft: -100 + 'px' }, 8000, 'linear', function() { $(this).remove(); }); $('.dm-list-cont').append(div); $(this).prev().val(''); $('.dm-list-cont').scrollTop($('.dm-list-cont')[0].scrollHeight); } else { alert('请输入弹幕信息'); } })
↑上面代码改变,会自动显示代码结果
jQuery调用版本:
1.11.3
<!doctype html><html><head><meta charset="utf-8"><title>简单的发弹幕效果-www.sucainiu.com</title><script src="https://libs.baidu.com/jquery/1.11.3/jquery.min.js"></script><style>
</style></head><body>
<script>
</script>
</body></html>
立即下载
收藏
积分说明:注册即送10牛币,每日签到可获得5牛币,成为VIP会员可永久免牛币下载!
充值积分
充值会员
更多说明»
代码描述:一个简单的弹幕效果 ,能力有限,不喜勿喷
JS焦点图轮播效果
实现复杂的TAB切换效果
讨论这个常用代码(0)
回答他人问题或分享心得会奖励牛币
〒_〒 居然一个评论都没有……
文明上网,理性发言! 😉 阿里云幸运券,
戳我领取
发表评论
提交回复
我的积分余额:
0
已下载次数:
962
所需牛币:
5
开始下载
牛币获取:
签到、评论、充值
» 在线充值
(10牛币=1元)
成为VIP可永久免积分下载全部常用代码
» 查看详情
VIP
客服
签到
充值