简体   繁体   English

ColorBox不会动态更改宽度

[英]ColorBox doesn't Change Width Dynamically

I am using Jquery colorbox plugin at my HTML application. 我在我的HTML应用程序中使用Jquery colorbox插件。 There are two divs at my page. 我的页面上有两个div。 One is at left and one is at right . 一个在left ,一个在right I want that. 我要那个。 At the beginning right div's display is none . 在最right div's display is none When I click somewhere at my left div right div's display becomes block . 当我单击左div的某个位置时,右div's display becomes block However because of the size of colorbox place second div display's under first div and a scrollbar appears. 但是,由于颜色框的大小,将第二个div显示器放在第一个div下,并出现滚动条。 I don't want that I want it to locate at right I mean I want colorbox to calculate its width again automatically (If possible I don't want to declare a width to fix it) 我不想让它位于右侧,我的意思是I want colorbox to calculate its width again automatically (如果可能,我不想声明一个宽度来修复它)

PS 1: My left and right div's css': PS 1:我的左右div的CSS:

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

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

When I don't hide (I use Jquery .show() ) second div(right div): 当我不隐藏(我使用Jquery .show() )第二个div(右div)时:

one of is at right other at left. 其中之一在右侧,另一在左侧。

However when I hide (I use Jquery .hide() ) second and after I show it (I do $.colorbox.resize(); ) my second div appears at bottom of first one(not at right). 但是,当我第二次隐藏(我使用Jquery .hide() )并在显示它之后(我执行$.colorbox.resize(); )时,我的第二个div出现在第一个div的底部(不在右侧)。

PS 2: I get my colorbox content from an external file PS 2:我从外部文件获取我的颜色盒内容

colorbox changes its height automatically but doesn't change width. colorbox会自动更改其高度,但不会更改宽度。 So I did that: 所以我做到了:

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

只需致电:

$.colorbox.resize();

Try this 尝试这个

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

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM