JQuery colorbox doesn't look right the first time and then fine after that

I am trying to dynamically (using ajax) get some content and create modal with it (using the colorbox plugin). The problem is that the content has multiple images in it. I think that the modal does not take them into account in calculating the height or width or something like that. Therefore, if you close the modal and then open it, it looks great. (The first time you open it, it has scrollbars to access the rest of the modal model).

Ideas?

0
source share
4 answers

Looks like you just need to add the height and width attributes of the image. For instance:

<img src="/path/to/image.jpg" width="100px" height="100px" />
+3
source

@Matthew, :

: , Ajax, DOM ColorBox . , .

, .

ColorBox, , , , , .

. http://colorpowered.com/colorbox .

+3

:

jQuery('.colorbox').colorbox({
  width:700,
  height:460
});
0

:

jQuery('.colorbox').colorbox({
        onComplete: function () {
            $(this).colorbox.resize();
        }
});
0

Source: https://habr.com/ru/post/1657839/


All Articles