返回会动的云朵案例...登陆

会动的云朵案例

皮皮爱吃瓜子2018-11-27 21:54:24313
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head>
<title>会动的云朵</title>
<script type="text/javascript" src="jquery.js"></script>
<style type="text/css">
*{margin: 0px;padding: 0px;}
body{background: url("bg.jpg") no-repeat center top #ccc;}
.yun{width: 350px;height: 150px;background: url(yun1.png) no-repeat;position: relative;left: 500px;top: 10px;}
</style>
<script type="text/javascript">
$(document).ready(function(){
$(".yun").animate({
opacity: "0",
left: Math.random()*500,
},10000);
$(".yun").animate({
opacity: "1",
left: Math.random()*1000,
},10000);
$(".yun").click(function(){
$(this).stop();
})
})
</script>
</head>
<body>
<div class="yun"></div>
</body>
</html>

1,设置背景图片bg.jpg,蓝天白云,居中,不重复显示,多余背景色为灰色#ccc

body{background: url("bg.jpg") no-repeat center top #ccc;}

2,设置div的大小,背景图片云朵yun.png,不重复显示,相对定位,距离左边500px,距离上边10px

.yun{width: 350px;height: 150px;background: url(yun1.png) no-repeat;
position: relative;left: 500px;top: 10px;}

3,设置div云的动画效果,距离左边距离,Math.random()*500为随机0~1*500,速度10000

$(".yun").animate({
    opacity: "0",
    left: Math.random()*500,
},10000)

yun1.pngbg.jpg

最新手记推荐

• 用composer安装thinkphp框架的步骤• 省市区接口说明• 用thinkphp,后台新增栏目• 管理员添加编辑删除• 管理员添加编辑删除

全部回复(0)我要回复

暂无评论~
  • 取消回复发送