关于js的动画效果

本文详细介绍了如何使用HTML、CSS和jQuery来创建网页中的动态效果,包括元素的隐藏和显示、淡入淡出动画以及尺寸变化。此外,还展示了如何通过JavaScript和CSS操作改变元素样式。
摘要由CSDN通过智能技术生成

<html>

    <head>

   <title>zz Web</title>

   <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>

   

<style>

    .redbox{width: 100px;height: 100px;background-color: red;position: absolute;}

    .bluebox{width: 100px;height: 100px;float:left;background-color: blue;display: none;}

    .yellowbox{width: 100px;height: 100px;float:left;background-color:yellow;display: none;}

</style>

</head>

    <body>

     <div id ="d"class = "redbox"></div>

     <div id ="c"class = "bluebox">Hello</div>

     <div id ="b"class = "yellowbox">zz</div>

     <button>begin</button>

     

    </body>

</html>

   <script>

    //常用效果

   

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

        $("#d").hide(2000);//隐藏

    })

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

        $("#c").show(2000);//展示

    })

    $("button").mouseenter(function(){

        $("#b").toggle(2000);//切换

    })

    //然后淡入和滑动也是类似就不演示了

   

   

    //动画

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

        $("#d").animate({

            left:'200px', width:'200px',height:'200px'

        }).animate({

            top:'200px', width:'200px',height:'200px'

        }).animate({

            left:'0px', width:'200px',height:'200px'

        }).animate({

            top:'0px', width:'200px',height:'200px'

        });

    });//注意这个指令是执行一个操作以后,第二个才做是在第一个操作的基础上进行。

    //其他几个动画指令也可以连接起来完成此操作

     

    //cs操作

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

        $("#d").css("width","500px");

    })

   </script>

  • 9
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值