Colorbox doesn't open at proper height when first opened

后端 未结 4 675
臣服心动
臣服心动 2021-02-13 18:12

So I\'m using the colorbox plugin for a contact form. I am just the default colorbox properties, so it should automatically adjust to the div it contains (right?).

Well

4条回答
  •  伪装坚强ぢ
    2021-02-13 18:47

    I wasn't using images so the accepted answer didn't work for me. Also, it only happened when using inline: true and appeared to off by the height of the X button in the bottom right. To fix it, I added a new property called inlineHeightAdjustment and then used it within the getHeight function.

    In jquery.colorbox.js:

    function getHeight() {
       settings.h = settings.h || $loaded.height();
       settings.h = settings.mh && settings.mh < settings.h ? settings.mh : settings.h;
       // Adjust height for inline boxes
       settings.h = settings.inline ? settings.h + settings.inlineHeightAdjustment : settings.h;
       return settings.h;
    }
    

    Then on my pages:

    $(".inlineColorBox").colorbox({
       inline: true,
       inlineHeightAdjustment: 25,
    });
    

    You could probably make it better by accepting a string so you could specify em, px, %, etc. but I knew I wanted pixels thus the numerical value assumption.

提交回复
热议问题