首页 > Web开发 > 详细

CSS平滑过渡动画:transition

时间:2017-04-06 09:29:28      阅读:265      评论:0      收藏:0      [点我收藏+]
<html>
  <head>
    <link href="http://cdn.bootcss.com/twitter-bootstrap/3.0.2/css/bootstrap.css" rel="stylesheet">
    <style>
      body{
        margin-top: 30px;
      }
      .box {
          width: 400px; padding: 15px;  background-color: #f0f3f9;
      }
      .content {
          height: 0; position: relative;  overflow: hidden;
          -webkit-transition: height 0.6s;
          -moz-transition: height 0.6s;
          -o-transition: height 0.6s;
          transition: height 0.6s;
      }
      .content img {  
          position: absolute;  bottom: 0;
      }
      .block{
        margin: 20px 20px 20px 0;
        width:100px;
        height:100px;
        background:blue;
        transition:background 2s, width 2s;
      }

      .block:hover{
        width:300px;
        background:red;
      }

    </style>
  </head>
  <body>
    <div class="container">
      <div class="block"></div>
      <a href="javascript:" class="btn btn-primary" id="button">点击展开图片</a>
      <div id="more" class="content">
          <img src="http://i1.hoopchina.com.cn/u/1403/26/425/2709425/3076ecc2.jpg" height="191" />
      </div>
    </div>


    <script>
      (function() {
          var Btn = document.getElementById("button"),
              More = document.getElementById("more");
          
          var display = false;
          
          Btn.onclick = function() {
              display = !display;
              More.style.height = display? "192px": "0px"
              return false;
          };
      })();
    </script>
  </body>
</html>

技术分享

 

CSS平滑过渡动画:transition

原文:http://www.cnblogs.com/littlewriter/p/6671864.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!