search

Home  >  Q&A  >  body text

javascript - How to use Jquery to achieve the animation effect of opening the animation from the middle to the upper and lower sides. Thank you, masters!

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
</head>
<style>
    *{margin:0;padding:0}
    .view{width: 200px;height:0;margin:0 auto;background: #000;display:none}
    .hit{display: block;margin: 0 auto}
</style>
<body>
<p class="view">asddddddddddd</p>
<button class="hit">点击</button>
</body>
<script>
    $(".hit").on("click",function(){
       $(".view").animate({height:"200px"},2000)
               .css("display","block")
    })
</script>
</html>
巴扎黑巴扎黑2746 days ago658

reply all(1)I'll reply

  • 我想大声告诉你

    我想大声告诉你2017-05-19 10:40:21

    $(".hit").on("click",function(){
        
       $(".view").css({position:"relative",top:"100px",height:"0"}).animate({height:"200px",top:0},2000)
               .css("display","block")
    })

    reply
    0
  • Cancelreply