jQuery animate working in fiddle but not smooth online

后端 未结 2 941
情书的邮戳
情书的邮戳 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:48

    Try using single click event handler for animations with .animate() easings property set to "linear", css transition for effects, set width of .middle div elements to 33%

    $(".middle div").click(function() {
    
      $(this).siblings().animate({
        width: "10%",
        opacity: 0.6
      }, 0, "linear");
     
      $(this).animate({
        width: "80%",
        opacity: 1
      }, 0, "linear");
      
    });
    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 {
      width: 33%;
      height: 100%;
      background-color: red;
    }
    #b {
      width: 33%;
      height: 100%;
      background-color: blue;
    }
    #c {
      width: 33%;
      height: 100%;
      background-color: green;
    }
    .wrapper {
      height: 90vh;
      overflow: hidden;
    }
    #a,
    #b,
    #c {
      transition: width 500ms, opacity 500ms;
    }
    
    
    1
    2
    3

    jsfiddle http://jsfiddle.net/tJugd/3798/

提交回复
热议问题