Can I have two instances of Fancybox 2.0?

前端 未结 2 1210
情深已故
情深已故 2021-01-29 01:47

I have Fancybox 2.0 installed on my site, modified slightlyto look like the Facebook image preview box. I want to have a second \"instance\" of Fancybox, but for it to be positi

相关标签:
2条回答
  • 2021-01-29 02:03

    I don't think it is possible to have two instances of fancybox "at the same time" by default (version 2 and previous). If you are good at jQuery you may try to modify the original script (but it would be like re-inventing the wheel).

    The only modal box I have seen doing that is jQuery Tools Overlay - http://jquerytools.org/demos/overlay/multiple.html

    0 讨论(0)
  • 2021-01-29 02:05

    yes you can... I did it on my web site..

    first fancybox ues..

    .fancybox-wrap {
    margin: Xpx 0 0 Ypx;
    }
    

    to position you box..

    to dynamically set the position... you need to do two things... A: add a javascript before document.ready() fuunction B: add a onclick in you hyperlink...

    so when somebody click the link ,it will change the css before fancybox appear..

    the java script as follow (I get from the web, it is a function to dynamically change CSS value)

        function css(selector, property, value) {
    for (var i=0; i<document.styleSheets.length;i++) {//Loop through all styles
    //Try add rule
    try { document.styleSheets[i].insertRule(selector+ ' {'+property+':'+value+'}',
    document.styleSheets[i].cssRules.length);
    } catch(err) {try { document.styleSheets[i].addRule(selector, property+':'+value);} catch(err)
    {}}//IE
    }
    }
    

    the hyper link example:

    <a class="fancybox fancybox.iframe" href="showmybox.html"  onclick="css('.fancybox-
    wrap', 'margin', '-100px 0 0 250px')">
    

    (this will show you box at up-right corner)

    0 讨论(0)
提交回复
热议问题