2012-01-30 128 views
0

enter image description herejQuery的手風琴右側

幾個小時我一直在嘗試一個額外的圖標添加到jQuery的手風琴項目標題的右側。我有以下的代碼,但有3個問題:

1)摺疊時我的項目標頭具有0高度
2)將下列項目名稱的位置是關閉的,例如,在「第2」我的例子。
3)沒有顯示在我的項目內容
4)我想避免硬編碼的大小和位置儘可能

我的代碼(你可以從這裏下載所有必要的文件箭頭:http://dl.dropbox.com/u/12893123/accordion.zip)是這樣的:

<html> 
<head> 
<script language="JavaScript" src="jquery.js"></script> 
<script language="JavaScript" src="jquery-ui.custom.js"></script> 
<link rel="stylesheet" type="text/css" href="./css/ui-lightness/jquery-ui-1.8.17.custom.css"></script> 
</head> 
<body> 
<script> 
$(function() { 
    var stop = false; 
    $("#accordion div").click(function(event) { 
     if (stop) { 
      event.stopImmediatePropagation(); 
      event.preventDefault(); 
      stop = false; 
     } 
    }); 
    $("#accordion") 
     .accordion({ 
      header: "> div > div" 
     }) 
     .sortable({ 
      axis: "y", 
      handle: "div", 
      stop: function() { 
       stop = true; 
      } 
     }); 
}); 
</script> 

<style type="text/css"> 
div.div1 { 
    background: red; 
    position:relative; 
} 
div.div2 { 
    background: green; 
    float: left; 
} 
div.div3 { 
    background: yellow; 
    float: right; 
} 
div.div4 { 
    clear: both; 
} 

</style> 

    <div id="accordion"> 
     <div> 
      <div class="div1"><div class="div2"><a href="#">Section 1</a></div><div class="div3"><img src="delete_icon.gif"></img></div></div> 
      <div class="div4"> 
       <p>Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate.</p> 
      </div> 
     </div> 
     <div> 
      <div><a href="#">Section 2</a></div> 
      <div> 
       <p>Sed non urna. Donec et ante. Phasellus eu ligula. Vestibulum sit amet purus. Vivamus hendrerit, dolor at aliquet laoreet, mauris turpis porttitor velit, faucibus interdum tellus libero ac justo. Vivamus non quam. In suscipit faucibus urna. </p> 
      </div> 
     </div> 
     <div> 
      <div><a href="#">Section 3</a></div> 
      <div> 
       <p>Nam enim risus, molestie et, porta ac, aliquam ac, risus. Quisque lobortis. Phasellus pellentesque purus in massa. Aenean in pede. Phasellus ac libero ac tellus pellentesque semper. Sed ac felis. Sed commodo, magna quis lacinia ornare, quam ante aliquam nisi, eu iaculis leo purus venenatis dui. </p> 
       <ul> 
        <li>List item one</li> 
        <li>List item two</li> 
        <li>List item three</li> 
       </ul> 
      </div> 
     </div> 
     <div> 
      <div><a href="#">Section 4</a></div> 
      <div> 
       <p>Cras dictum. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aenean lacinia mauris vel est. </p><p>Suspendisse eu nisl. Nullam ut libero. Integer dignissim consequat lectus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. </p> 
      </div> 
     </div> 
    </div> 

</body> 
</html> 

回答

0

終於找到了解決辦法。我剛添加overflow: auto;div1,並修復了所有問題。