jQuery animate working in fiddle but not smooth online

后端 未结 2 904
情书的邮戳
情书的邮戳 2021-01-14 04:18

I\'ve made a sort of accordion with three expanding divs (#a, #b, #c) in fiddle, but when I save it locally and open it in a browser t

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-14 04:54

    Try this

    window.onload = function() {
        [].forEach.call(document.querySelectorAll('.inner'), function(el) {
          el.addEventListener('click', function(e) {
            this.parentElement.className = 'middle ' + this.id;
          });
        });
    
      } //]]>
    div.inner {
      max-width: 0;
      display: table-cell;
      overflow: hidden;
    }
    div.outer {
      display: table;
      overflow: hidden;
      width: 100%;
      height: 100%;
    }
    div.middle {
      display: table-row;
      overflow: hidden;
    }
    #holder {
      width: 100%;
      height: 100%;
      margin: 0px auto;
      overflow: hidden;
      position: fixed;
    }
    #a {
      height: 100%;
      background-color: red;
    }
    #b {
      height: 100%;
      background-color: blue;
    }
    #c {
      height: 100%;
      background-color: green;
    }
    #a,
    #b,
    #c {
      width: 10%;
      opacity: 0.6;
      transition: all 3000ms;
    }
    .middle.a #a,
    .middle.b #b,
    .middle.c #c {
      width: 80%;
      opacity: 1;
    }
    .wrapper {
      height: 90vh;
      overflow: hidden;
    }
    
    
    
      
      - jsFiddle demo
    
    
      
    1
    2
    3

提交回复
热议问题