2013-10-16 62 views
0

我正在使用jquery 1.9.1。在我的手風琴中,根據heightStyle值(即'fill'的'content')分配高度。Jquery手風琴高度溢出

在其中一個窗格中,我使用for循環來呈現列表。無論我設置什麼樣的屬性,這個窗格總是滿溢。

這裏是我的JSP:

<style> 
     #accordion-resizer { 
      padding: 10px; 
      width: 350px; 
      height: 220px; 
     } 
</style> 
<script> 
     $(function() { 
      $("#accordion").accordion({ 
       heightStyle: "fill", 
       autoHeight: false 
      }); 
     }); 
     $(function() { 
      $("#accordion-resizer").resizable({ 
       minHeight: 140, 
       minWidth: 200, 
       resize: function() { 
        $("#accordion").accordion("refresh"); 
       } 
      }); 
     }); 
</script> 
</head> 
<body> 
    <div id="accordion-resizer" class="ui-widget-content"> 
     <div id="accordion" style="font-size: medium;"> 
      <h3>Projects</h3> 
      <div> 
       <p> 
       <form:form method="post" modelAttribute="projects" > 
        <c:forEach items="${projects}" var="project" varStatus="status"> 
         <tr> 
          <td align="center">${status.count}</td> 
          <td><input name="projects[${status.index}].projectId" 
           value="${project.projectId}" /><br /></td> 
         </tr> 
        </c:forEach> 

        <button type="submit"></button> 
       </form:form> 
       </p> 
      </div> 
      <h3>Excepteur sint occaecat</h3> 
      <div> 
       <p>Lorem Ipsum</p> 
       <p>tempora incidunt ut labore</p> 
      </div> 
      <h3>Other Info</h3> 
      <div> 
       <p>Neque porro quisquam </p> 
       <p>Sed eleifend nonummy </p> 
      </div> 
     </div> 
    </div> 

第一個窗格,加載後會展開的形式,因此,溢出。其他窗格正常高度的其他窗格也採用這個新高度。 我曾嘗試:

heightStyle: 「補」 和 heightStyle: 「內容」

都無法從吹出來阻止第一個窗格。

+0

如果你使用HTML只(不帶JSP)做同樣的事情發生呢? – jahroy

+0

不,它沒有。這隻發生在JSP內 – tempusfugit

回答

0

嘗試了很多後,終於找到了解決方案。發生這種情況是因爲手風琴窗格長度不定。 此設置可防止窗格溢出,增加了一個不錯的滾動條

#accordion .ui-accordion-content { 
    max-height: 500px; 
    overflow-y: auto; 
} 

謝謝