Search code examples
jquerypositionfancybox

Fancybox 2.0 close button to the top corner of the window


How do I move the close button of Fancybox 2.0 from the top corner of the dialog box to the top corner of the screen? I asked on the FB Google Group and had no response, so thought to ask here, since a lot of FB questions are apparently being asked here, especially for FB 2.0.


Solution

  • Change style for close button from:

    #fancybox-close {
        position: absolute;
        top: -15px;
        right: -15px;
        ...
    }
    

    to something like:

    #fancybox-close {
        position: fixed;
        top: 15px;
        right: 15px;
        ...
    }
    

    Though, in that case close button won't move even if you scroll the page.

    Have a look, for example, at this for more information about CSS positioning.