jquery fancybox弹窗 需要注意的问题

要想使用fancybox做出弹窗效果,需要以下几个步骤:
第一步.引入fancybox样式文件与jQuery以及fancybox的js文件(注意link标签要把type和rel加上,以及jQuery.js文件要在fancybox.js文件之前,之前出错就是因为这个小细节没注意,蠢爆了)
<span style="white-space:pre">	</span><link href="css/fancybox.css" type="text/css" rel="stylesheet" />
        <script type="text/javascript" src="js/jquery.js"></script>
        <script type="text/javascript" src="js/jquery.fancybox.js"></script>
第二步.编写html(一个是带a标签点击的,一个是要弹出的div)
<body>
        <div class="demo">
             <h4>Demo3:加载DIV,并固定在浏览器中央</h4>
             <p><a id="showdiv" href="#inline" title="显示一个DIV内容">点击这里</a>加载本页中一个隐藏的DIV。</p>
        </div>


        <div style="display:none">
             <div id="inline" style="width:400px; height:160px; overflow:auto;">
                <p>
                    <img src="images/example/s1.gif" alt="" style="float:left; margin:4px" />
                    我们在设计WEB前端时,从前端交互设计的角度考虑,如何使用让产品易用,有效而让人愉悦的技术,了解目标用户和他们的期望,了解用户在同产品交互时彼此的行为,了解“人”本身的心理和行为特点,同时,还包括了解各种有效的交互方式,并对它们进行增强和扩充。
                </p>
                <p>交互设计是一个过程,它不仅仅是画线框图。交互设计最关键的两个环节是页面流程和页面布局,前者建立清晰的架构和严密的逻辑,后者整合零散的信息并确定分明的主次关系。这一切都是为了我们的终极目标——让我们的界面符合用户的预期,不带给他们任何的意外。一切都在用户的意料之中。
                </p>
             </div>
        </div>
    </body>
第三步. 在页面中编写jq语句调用fancybox
<script type="text/javascript">
            $(document).ready(function(){
                $("#showdiv").fancybox();
            });
</script>

(这样就可以把弹窗效果做出来啦~第一次做记录一下,怕自己以后忘了  虽然看着很简单,但是我却研究了好久,后面还是问了老大才帮我把这些小问题改过来了 多学习学习学习)


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
How to use 1. Setup Include nessesary JS files (FancyBox uses pngFix to fix IE png transparency). --------------------------- /* required */ <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/jquery.fancybox.js"></script> /* optional */ <script type="text/javascript" src="js/jquery.pngFix.js"></script> <script type="text/javascript" src="js/jquery.metadata.js"></script> -------------------------------------------- Include FancyBox CSS file. Dont forget to change image paths. -------------------------------------------- <link rel="stylesheet" href="css/fancybox.css" type="text/css" media="screen"> -------------------------------------------- 2. Add your images Add images and wrap them with a link to the zoomed version -------------------------------------------- <a href="image_big.jpg"><img src="image_small.jpg" alt=""/></a> -------------------------------------------- Optional: Use the title attribute if you want to show a caption Optional: Use the rel attribute to group images 3. Use the plugin Sample examples: -------------------------------------------- $(document).ready(function() { $("p#test1 a").fancybox(); $("p#test2 a").fancybox({ 'hideOnContentClick': true }); $("p#test3 a").fancybox({ 'zoomSpeedIn': 0, 'zoomSpeedOut': 0, 'overlayShow': true }); }); ------------------------------------------- Available options hideOnContentClick Hides FancyBox when cliked on zoomed item (false by default) zoomSpeedIn Speed in miliseconds of the zooming-in animation (no animation if 0) zoomSpeedOut Speed in miliseconds of the zooming-out animation (no animation if 0) frameWidth Default width for iframed and inline content frameHeight Default height for iframed and inline content overlayShow If true, shows the overlay (false by default) overlayOpacity Opacity of overlay (from 0 to 1) itemLoadCallback Custom function to get group items (see example on this page source) Comments

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值