2012-11-18 38 views
0

我有一系列浮動div,我想在水平線上旋轉到無窮大(繼續浮動)。這些div需要在有限寬度div內繼續。最終,我想按左右的div /按鈕滾動項目(與使用滾動條)。Floating Div - 停止清除/包裝

我無法讓div保持在其浮動狀態。一旦他們在父div內空間用完,他們開始包裝。

有什麼辦法可以繞過包裝嗎?一旦我弄清楚了,下一步就是使用jQuery來獲取水平向左/向右移動,以便它重複水平滾動。

這裏是小提琴我所做的和代碼:

http://jsfiddle.net/stfzy/8/

HTML:

<div id='container'> 
    <div id='arrowL'> 
    </div> 
    <div id='arrowR'> 
    </div> 
    <div class='list'> 
     <div class='item'> 
     </div> 
     <div class='item'> 
     </div> 
     <div class='item'> 
     </div> 
     <div class='item'> 
     </div> 

    </div> 

CSS:

#container{ 
width:340px; 
    height:50px; 
} 

.list{ 
    background:grey; 
width:300px; 
    height:50px; 
    float:left; 
} 


#arrowR{ 
background:yellow; 
    width:20px; 
    height:50px; 
    float:right; 
} 


#arrowL{ 
background:yellow; 
    width:20px; 
    height:50px; 
    float:left; 
} 

.item{ 
    background:green; 
width:140px; 
    height:40px; 
    margin:5px; 
    float:left; 
} 

任何和讚賞所有幫助。謝謝!

+1

其實我不理解你的問題在這裏,究竟你所要求的 –

+0

不能使用float這樣的事情。在相對定位的外部div內使用絕對定位。 –

回答

0

試試這個,通過在溢出的容器內包裝list類:hidden。然後你可以使用JQuery來做任何你想要的內部div。

Sample Fiddle

#list-container { 
overflow:hidden;  
width: 300px; 
} 

.list{ 
background:grey; 
min-width:700px; 
float:left; 
} 
+0

這不會幫助...大聲笑...你正在隱藏它們,而不是正確的格式 –

+0

他將使用JQuery滾動項目。所以只要項目保持水平線,應該是好的。 –

+0

@ c2這是令人困惑的部分,如果他想要一個jQuery解決方案,他已經爲他的問題標記了錯誤的標籤,其次我甚至要做同樣的事情,但這並沒有幫助.. –