Search code examples
jqueryfancybox

Position Fancybox 2 manually


I can not for the life of me, figure out how I can reposition Fancybox 2 to use left: 47px; and top: 147px

I read through the source code, and without hacking it, I don't see a way to override the positioning.

Setting autoCenter to false only stops auto-centering after the first time it does it.

Using jQuery to change the CSS, or giving a custom wrapper to apply the CSS doesn't work either, because Fancybox always adds inline CSS which overwrites all my attempts.

Is there a way to tell Fancybox to stop positioning itself and to use my absolute positioning?


Solution

  • You can override inline CSS styles using the !important modifier.

    For the Fancybox use case the following will override the JavaScript positioning:

    .fancybox-wrap { 
      top: 147px !important; 
      left: 47px !important; 
    }