[英]Colour Animation in Javascript
我希望我的文本从白色逐渐变为黑色,而背景颜色从黑色逐渐变为白色,您有什么想法吗?
In jQuery you can animate the colour of text by default using: 在jQuery中,您可以默认使用以下方式设置文本颜色的动画:
$('#element').animate({ color: 'red' }, 1500);
But background animations cannot be done by default and require a plugin (links below). 但是默认情况下无法完成背景动画,并且需要插件(下面的链接)。
jQuery: http://www.jquery.com/ jQuery: http : //www.jquery.com/
Colour plugin: http://plugins.jquery.com/project/color 颜色插件: http : //plugins.jquery.com/project/color
Enjoi ^.^ Enjoi ^。^
This could be achieved easily with the jQuery color plugin : 这可以通过jQuery color插件轻松实现:
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript" src="jquery.color.js"></script>
<script type="text/javascript">
$(function() {
$('#foo').animate({
backgroundColor: '#fff',
color: '#000'
}, 'slow');
});
</script>
</head>
<body>
<div id="foo" style="background-color: black;">Some Text</div>
</body>
</html>
See it in action here . 看到它在这里行动 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.