Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/429.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript CSS切换自动高度不工作的过渡动画_Javascript_Jquery_Html_Css - Fatal编程技术网

Javascript CSS切换自动高度不工作的过渡动画

Javascript CSS切换自动高度不工作的过渡动画,javascript,jquery,html,css,Javascript,Jquery,Html,Css,我很难用自动高度解决CSS转换问题,不知道其他人是否会有任何线索和建议。提前谢谢 下面是一个自动高度的示例,我正在尝试使其工作,但转换不起作用,但自动高度对于响应站点是理想的: Javascript: $(document).ready(function(){ $(".button").click(function(){ $(".test").toggleClass("collapse"); }); }); CSS: 下面是一个具有特定像素的特定高度的示例,但请注意,这并不理

我很难用自动高度解决CSS转换问题,不知道其他人是否会有任何线索和建议。提前谢谢

  • 下面是一个自动高度的示例,我正在尝试使其工作,但转换不起作用,但自动高度对于响应站点是理想的:
  • Javascript:

    $(document).ready(function(){
      $(".button").click(function(){
        $(".test").toggleClass("collapse");
      });
    });
    
    CSS:

  • 下面是一个具有特定像素的特定高度的示例,但请注意,这并不理想,因为站点响应速度快,并且由于浮动列表,高度始终会发生变化:
  • CSS:

    有人知道如何让示例1起作用吗


    谢谢

    谢谢大家的反馈。以下是我使用的最终解决方案,它允许响应更快、更平滑的切换:


    谢谢大家的反馈。以下是我使用的最终解决方案,它允许响应更快、更平滑的切换:


    试试下面的方法。按李和高度走,这样就不会有任何东西被切断。根据需要进行调整

    $(文档).ready(函数(){
    $(“.button”)。单击(函数(){
    $(“.test”).toggleClass(“扩展”,5000);
    });
    });
    
    。测试ul{
    宽度:50%;
    溢出:隐藏;
    高度:自动;
    -webkit转换持续时间:0.8s;
    -moz转换持续时间:0.8s;
    -o-过渡持续时间:0.8s;
    过渡时间:0.8s;
    }
    李测试{
    浮动:左;
    宽度:100px;
    }
    .测试li:非(:第n种类型(-n+10)){
    宽度:100px;
    显示:无;
    }
    .测试{
    宽度:50%;
    高度:500px;
    -webkit转换持续时间:0.8s;
    -moz转换持续时间:0.8s;
    -o-过渡持续时间:0.8s;
    过渡时间:0.8s;
    }
    .test.ul.li{
    显示:块;
    }
    
    
    • 马莱苏阿达
    • 佩伦茨克
    • 斜角肌
    • 阿梅特码头
    • 马莱苏阿达
    • 佩伦茨克
    • 斜角肌
    • 阿梅特码头
    • 马莱苏阿达
    • 佩伦茨克
    • 斜角肌
    • 阿梅特码头
    • 马莱苏阿达
    • 佩伦茨克
    • 斜角肌
    • 阿梅特码头
    • 马莱苏阿达
    • 佩伦茨克
    • 斜角肌
    • 阿梅特码头
    • 马莱苏阿达
    • 佩伦茨克
    • 斜角肌
    • 阿梅特码头
    • 马莱苏阿达
    • 佩伦茨克
    • 斜角肌
    • 阿梅特码头
    • 马莱苏阿达
    • 佩伦茨克
    • 斜角肌
    • 阿梅特码头
    • 马莱苏阿达
    • 佩伦茨克
    • 斜角肌
    • 阿梅特码头
    • 马莱苏阿达
    • 佩伦茨克
    • 斜角肌
    • 阿梅特码头
    • 马莱苏阿达
    • 佩伦茨克
    • 斜角肌
    • 阿梅特码头
    • 马莱苏阿达
    • 佩伦茨克
    • 斜角肌
    • 阿梅特码头
    • 马莱苏阿达
    • 佩伦茨克
    • 斜角肌
    • 阿梅特码头
    • 马莱苏阿达
    • 佩伦茨克
    • 斜角肌
    • 阿梅特码头
    • 马莱苏阿达
    • 佩伦茨克
    • 斜角肌
    • 阿梅特码头
    • 马莱苏阿达
    • 佩伦茨克
    • 斜角肌
    • 阿梅特码头
    • 马莱苏阿达
    • 佩伦茨克
    • 斜角肌
    • 阿梅特码头
    • 马莱苏阿达
    • 佩伦茨克
    • 斜角肌
    • 阿梅特码头
    • 马莱苏阿达
    • 佩伦茨克
    • 斜角肌
    • 阿梅特码头
    • 马莱苏阿达
    • 佩伦茨克
    • 斜角肌
    • 阿梅特码头
    • 马莱苏阿达
    • 佩伦茨克
    • 斜角肌
    • 阿梅特码头
    • 马莱苏阿达
    • 佩伦茨克
    • 斜角肌
    • 阿梅特码头

    试试下面的方法。按李和高度走,这样就不会有任何东西被切断。根据需要进行调整

    $(文档).ready(函数(){
    $(“.button”)。单击(函数(){
    $(“.test”).toggleClass(“扩展”,5000);
    });
    });
    
    。测试ul{
    宽度:50%;
    溢出:隐藏;
    高度:自动;
    -webkit转换持续时间:0.8s;
    -moz转换持续时间:0.8s;
    -o-过渡持续时间:0.8s;
    过渡时间:0.8s;
    }
    李测试{
    浮动:左;
    宽度:100px;
    }
    .测试li:非(:第n种类型(-n+10)){
    宽度:100px;
    显示:无;
    }
    .测试{
    宽度:50%;
    高度:500px;
    -webkit转换持续时间:0.8s;
    -moz转换持续时间:0.8s;
    -o-过渡持续时间:0.8s;
    过渡时间:0.8s;
    }
    .test.ul.li{
    显示:块;
    }
    
    
    • 马莱苏阿达
    • 佩伦茨克
    • 斜角肌
    • 阿梅特码头
    • 马莱苏阿达
    • 佩伦茨克
    • 斜角肌
    • 阿梅特码头
    • 马莱苏阿达
    • 佩伦茨克
    • 斜角肌
    • 阿梅特码头
    • 马莱苏阿达
    • 佩伦茨克
    • 斜角肌
    • 阿梅特码头
    • 马莱苏阿达
    • 佩伦茨克
    • 斜角肌
    • 阿梅特码头
    • 马莱苏阿达
    • 佩伦茨克
    • 斜角肌
    • 阿梅特码头
    • 马莱苏阿达
    • 佩伦茨克
    • 斜角肌
    • 阿梅特码头
    • 马莱苏阿达
    • 佩伦茨克
    • 斜角肌
    • 阿梅特码头
    • 马莱苏阿达
    • .test.collapse ul {
      height: auto;
      
      .test.collapse ul {
      height: 500px;
      
      $(document).ready(function(){
          $(".button").click(function(){
              $(".collapse-list").toggleClass("collapse");
          });
      });
      
      <body>
        <p>Technicaly this dropdown menu looks like a simple height transition.</p>
        <p>But this pure css code also works this a variable number of choices in menu, working around the "height:auto" not taken into account by css transitions.</p>
          <input type="checkbox" id="menuOpen"></input>
          <label id="bouton" for="menuOpen"><span>Click on me !</span>
              <div id="menu">
                  <div id="masque">
                      <div class="choix" id="choix1">Choix 1</div>
                      <div class="choix" id="choix2">Choix 2</div>
                      <div class="choix" id="choix3">Choix 3 tr&egrave;s tr&egrave;s long pour voir la taille finale du menu</div>
                      <div class="choix" id="choix4">Choix 4</div>
                      <div class="choix" id="choix5">Choix 5</div>
                      <div class="choix" id="choix6">Choix 6</div>
                  </div>
              </div>
          </label>
      </body>
      
      body {
          font-family: sans-serif;
      }
      #menuOpen {
          display: none;
      }
      #bouton {
          position: absolute;
          left: 100px;
          top: 100px;
          width: 200px;
          height: 30px;
          background-color: lightgray;
          cursor: pointer;
      }
      #bouton > span {
          color: black;
          padding: 6px;
          line-height: 30px;
      }
      #menu {
          position: absolute;
          top: 100%;
          overflow: hidden;
          min-width: 100%;
          transition: transform 0.3s linear 0s, visibility 0.3s linear 0s;
          transform: translateY(-100%);
          visibility: hidden;
          color: white;
      }
      #menuOpen:checked + #bouton > #menu  {
          transform: translateY(0%);
          visibility: visible;
          transition: transform 0.3s linear 0s, visibility 0s linear 0s;
      }
      #menuOpen:checked + #bouton > #menu > #masque {
          transform: translateY(0%);
      }
      #masque {
          position: relative;
          background-color: gray;
          transform: translateY(100%);
          transition: transform 0.3s linear 0s;
      }
      .choix {
          white-space: nowrap;
          padding: 3px 6px;
      }
      .choix:hover {
          background-color: darkgray; 
      }