html animate颜色,利用jQuery的animate动画效果实现,文字可以随机变化颜色

本文介绍了如何使用Java实现视频弹幕功能,通过SreenText库实现动态文本显示,并提供了一个详细的教程链接,适合开发者学习相关技术。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

Java开发视频弹幕技术SreenText

*{margin:0;padding:0;}

body{background:#09c;font-size:12px;font-family:"微软雅黑";}

/*screen start*/

#click_screen{width:100px;height:40px;display:block;border:0;text-align:center;line-height:40px;text-decoration:none;font-size:21px;color:#fff;font-family:"微软雅黑";position:absolute;top:20px;left:20px;}

.screen{width:100%;height:100%;position:absolute;left:0;top:0;display:none;}

.screen .s_dm{}

.screen .s_dm .s_close{width:100px;height:40px;display:block;border:0;text-align:center;line-height:40px;text-decoration:none;font-size:21px;color:#c0c0c0;font-family:"微软雅黑";position:absolute;top:20px;right:20px;z-index:3;}

.screen .s_dm .s_close:hover{color:#fff;}

.screen .s_dm .s_show{position:relative;z-index:2;}

.screen .s_dm .s_show div{line-height:36px;font-size:24px;font-weight:bold;position:absolute;top:0;left:0;}

.screen .send{width:100%;height:80px;background:#000;position:absolute;bottom:0;z-index:2;}

.screen .send .s_con{width:100%;height:80px;text-align:center;line-height:80px;}

.screen .send .s_con .s_txt{width:700px;height:40px;border:0;font-size:18px;font-family:"微软雅黑";padding-left:12px;border-radius:3px 0 0 3px;outline:none;}

.screen .send .s_con .s_btn{width:100px;height:40px;background:#088;border:0;font-size:18px;font-family:"微软雅黑";color:#fff;cursor:pointer;border-radius:0 3px 3px 0;outline:none;}

.screen .send .s_con .s_btn:hover{background:#006c6c;}

.screen .s_dm .mask{width:100%;height:100%;position:absolute;top:0;left:0;background:#000;opacity:0.5;filter:alpha(opacity=50);z-index:1;}

/*end screen*/

点击弹幕

$(function(){

//点击展开

$("#click_screen").click(function(){

$(".screen").toggle(600);

});

$(".s_close").click(function(){

$(".screen").toggle(600);

});

//发表评论

$(".s_btn").click(function(){

var text=$(".s_txt").val();

$(".s_show").append("

"+text+"
");

init_screen();

});

$(".s_txt").keydown(function(){

var code = window.event.keyCode;

//alert(code);

if(code == 13)//回车键按下时,输出到弹幕

{

var text=$(".s_txt").val();

$(".s_show").append("

"+text+"
");

init_screen();

}

});

});

//初始化弹幕

function init_screen(){

var _top=0;

$(".s_show").find("div").show().each(function(){

var _left=$(window).width()-$(this).width();

var _height=$(window).height();

_top=_top+80;

if(_top>_height-100){

_top=80;

}

var time=10000;

if($(this).index()%2==0){

time=20000;

}

//设定文字的初始化位置

$(this).css({left:_left,top:_top,color:getRandomColor()});

$(this).animate({left:"-"+_left+"px"},time,function(){

});

});

}

//随机获取颜色值

function getRandomColor(){

return '#'+(function(h){

return new Array(7-h.length).join("0")+h

})((Math.random()*0x1000000<<0).toString(16))

}

c7a7458da97739127c417e52fd198618377ae2c7.jpg

详情教程请参照:http://www.tommydog.info

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值