zoukankan      html  css  js  c++  java
  • CSS平滑过渡动画:transition

    <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 中关于border-color 继承了color的说明
    关于飞书的相关开发案例
    好看的点赞设计
    较好的设计网站参考
    较好的B端设计体验 说明
    基于vue的流程图插件
    较好看的中后台模板(ui)
    前端笔记-201807
    前端笔记(201905-201906)
    前端笔记(201902-201904)
  • 原文地址:https://www.cnblogs.com/littlewriter/p/6671864.html
Copyright © 2011-2022 走看看