首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Div在切换div时摔倒。

Div在切换div时摔倒。
EN

Stack Overflow用户
提问于 2017-07-14 06:29:29
回答 2查看 74关注 0票数 1

我有两个内联div,其中一个内联div,我有两个div在彼此下面。JSFiddle

我在点击#notLoginStudentBtn时所做的事情,我正在切换#notLoginStudentBox,但在切换#notLoginStudentBtn之后,它正在下降。

我面临的另一个问题是在inline-blocked divs,我希望两个div都有相同的高度,也就是最小的div和更长的div将溢出垂直滚动体。我可以使用最大高度,但两个div都会根据元素的数量动态增长和收缩。

引用的JSFiddle链接:https://jsfiddle.net/govi20/vwc20vsz/

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-07-14 06:31:38

移除显示:内联块及以下css到此类:

代码语言:javascript
复制
.table_sorter_container {
   position: relative;
   float: left;
}

并且需要将高度设置为div (类似于高度):165 to;还需要设置高度:165 to

票数 2
EN

Stack Overflow用户

发布于 2017-07-14 06:38:10

用途:

代码语言:javascript
复制
#notLoginStudentBoxContainer {
  vertical-align: top;
}

代码语言:javascript
复制
$(document).ready(function(){
$("#notLoginStudentBtn").click(function() {
    
    $("#notLoginStudentBox").fadeToggle("slow", function(){
      if( $("#notLoginStudentBtn span").html() == "+"){
        $("#notLoginStudentBtn span").html("-");
      }
      else{
        $("#notLoginStudentBtn span").html("+");
      }
    });
  });
});
代码语言:javascript
复制
#notLoginStudentBoxContainer {
  vertical-align: top;
}
代码语言:javascript
复制
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<div class="testTable bottomBox" id="double-scroll" style="overflow-x: scroll; overflow-y: hidden;">
          
           <div id="table_sorter_container" style="display: inline-block;">
            <table id="table_sorter">
              <tr >
                <th>abc</th>
                <th>abc</th>
                <th>abc</th>
              </tr>
               <tr >
               <td>asasdas</td>
               <td>adasdasd</td>
               <td>adasdasdasd</td>
              </tr>
                              <tr >
               <td>asasdas</td>
               <td>adasdasd</td>
               <td>adasdasdasd</td>
              </tr> 
            </table>
          </div>
          
          <div id="notLoginStudentBoxContainer" style="display: inline-block;">
            <div id="notLoginStudentBtn"> Not Login Student <span>+</span>
                
              </div>
            <div id="notLoginStudentBoxContainer">
              <div id="notLoginStudentBox">
                  
                    
                  
                    
                  
                    
                      <p>
                        <span onclick="showProfile('33')" class="cursor">student12</span>
                      </p>
                    
                  
                    
                      <p>
                        <span onclick="showProfile('34')" class="cursor">student13</span>
                      </p>
                    
                  
                    
                      <p>
                        <span onclick="showProfile('35')" class="cursor">student14</span>
                      </p>
                    
                  
                    
                      <p>
                        <span onclick="showProfile('36')" class="cursor">student15</span>
                      </p>
                    
                  
              </div>
            </div>
            <div>
          </div>
        

      </div>

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45096133

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档