2011-11-16 97 views
0

我在我的HTML應用程序中使用Jquery colorbox插件。我的網頁上有兩個div。一個在left,另一個在right。我要那個。在開始right div's display is none。當我點擊我的左側div右側div's display becomes block。但是由於colorbox的大小,第二個div顯示在第一個div下面並出現一個滾動條。我不想,我希望它在正確的我的意思是I want colorbox to calculate its width again automatically定位(如果可能的話,我不想申報的寬度來修復它)ColorBox不動態調整寬度

任何想法?

PS 1: 我的左,右div的CSS':

.left { 
    float: left; 
    display: inline; 
} 

.right { 
    float: right; 
    display: inline; 
} 

當我不隱瞞(我使用jQuery .show())第二個div(右格):

其中一個位於左邊的其他位置。

然而,當我隱藏(我使用jQuery .hide())第二後,我表現出來(我做$.colorbox.resize();)我的第二個div出現在第一個(不正確)的底部。

PS 2:我從一個外部文件

回答

2

顏色框會自動更改其高度,但不會改變寬度。所以我做了:

$.colorbox.resize({width: pixelValue}); 
0

我的顏色框內容只要致電:

$.colorbox.resize(); 
+0

它會調整,但仍然是我的div不右它去了。如果我不隱藏第二個div,並使用colorbox,其中一個位於左側,另一個位於右側。 – kamaci

+0

我編輯了我的問題。 – kamaci

-1

試試這個

var contentHeight = $('.class').height(); 

var contentWidth = $('.class').width(); 

$.colorbox.resize({ height: contentHeight, width: contentWidth });