zoukankan      html  css  js  c++  java
  • 使用「max-height」实现自适应高度

    
    
    
    .tab-content{
      max-height: 0;
      overflow: hidden;
      -webkit-transition: max-height .8s;
      -moz-transition: max-height .8s;
      -ms-transition: max-height .8s;
      -o-transition: max-height .8s;
      transition: max-height .8s;
    }
    
    .tab{
        list-style-type: none;
      list-style-image: none;
      margin: 0;
      padding: 0;
      margin-top: 10px;
      overflow: hidden;
      
      border:1px solid #CCC;
      border-radius:5px;
      
      /* 动画差 */
      
      -webkit-transition: max-height .2s;
      -moz-transition: max-height .2s;
      -ms-transition: max-height .2s;
      -o-transition: max-height .2s;
      transition: max-height .2s;
    
    }
    
    
    .tab h2{
      cursor:pointer;
      padding:10px 20px;
      background: #EEE;
      border-top:1px solid #BBB;
      border-bottom:1px solid #BBB;
      margin:-1px 0;
      color:#333;
      
      -webkit-transition: background .3s;
      -moz-transition: background .3s;
      -ms-transition: background .3s;
      -o-transition: background .3s;
      transition: background .3s;
    }
    
    .tab h2:hover{
      background: lightblue;
    }
    
    .tab h2:hover ~ .tab-content{// 开始动画
      max-height: 200px;
    }
    
     <h1>CSS3 缓动手风琴动画效果(一丝)</h1>
        <p>使用「max-height」实现自适应高度</p>
    	<ul class="tab">
          <li>
            <h2>选项卡1</h2>
            <div class="tab-content">
            <p>隐藏的文字<br>
              隐藏的文字<br>
              隐藏的文字<br>
            </p>
            </div>
          </li>
          <li>
            <h2>选项卡2</h2>
            <div class="tab-content">
            <p>隐藏的文字<br>
              隐藏的文字<br>
              隐藏的文字<br>
              隐藏的文字<br>
              隐藏的文字<br>
              隐藏的文字
            </p>
            </div>
          </li>
    	</ul>
    

  • 相关阅读:
    数值分析之奇异值分解(SVD)篇
    windows/linux VPS云服务器限制IP访问,限制别人的IP访问网站方法
    WORDPRESS博客完美更换网站空间服务器的方法
    教你9个提升 Wordpress 网站安全性的方法
    Windows 2008 R2+iis7.5环境下Discuz!X3论坛伪静态设置方法
    各大型网站使用的服务器空间运行环境盘点
    VPS/云主机 如何试用远程连接登录主机服务器_
    Discuz! X论坛上传附件到100%自动取消上传的原因及解决方案
    Discuz! X3搬家后UCenter出现UCenter info: MySQL Query Error解决方案
    如何刷新DNS缓存
  • 原文地址:https://www.cnblogs.com/rubylouvre/p/3244120.html
Copyright © 2011-2022 走看看