对话框/Tips

带炫酷CSS3过渡动画jQuery模态窗口插件

阿里云

这是一款带 19 种炫酷 CSS3 过渡动画的 jQuery 模态窗口插件。该插件基于 Codrops 的 ModalWindowEffects 来制作,通过 jQuery 插件的方式来统一管理各种打开模态窗口的效果。

使用方法:

在页面中引入 jquery.niftymodals.css 和 jquery、jquery.niftymodals.js 文件。

也想出现在这里?联系我们
创客主机
  1. <link rel="stylesheet" href="dist/css/jquery.niftymodals.css">
  2. <script src="path/to/jquery.min.js"></script>                  
  3. <script src="dist/js/jquery.niftymodals.js"></script>

HTML 结构:

模态窗口的基本 HTML 结构如下:

  1. <div class="md-dialog md-effect-1 md-show" id="your-modal-id">
  2.     <div class="md-content">
  3.         <!-- your content -->
  4.     </div>
  5. </div>
  6. <div class="md-overlay"></div>

初始化插件:

在页面 DOM 元素加载完毕之后,可以通过在按钮或超链接上绑定 niftyModal()方法来打开模态窗口。

  1. $('#button-id').on('click',function(){
  2.   $('#modal-id').niftyModal();
  3. });

配置参数:

在对模态窗口初始化时,可以以对象的方式传入一些配置参数:

  1. $('#modal-id').niftyModal({
  2.     overlaySelector: '.md-overlay',//模态窗口遮罩层的class类
  3.     closeSelector: '.md-close',//模态窗口关闭按钮元素的class类
  4.     classAddAfterOpen: 'md-show',//Body control class
  5.     //This object will be available in the modal events
  6.     data: {
  7.       some_data: ''
  8.     },
  9.     //This option allow to attach a callback to a button with the class 'md-close'
  10.     buttons: [
  11.       {
  12.         class: 'btn-ok',
  13.         callback: function ( btn, modal, event ) {
  14.           //You can cancel the modal hide event by returning false
  15.           alert("You need to check your info!");
  16.           return false;
  17.         }
  18.       },
  19.       {
  20.         class: 'btn-cancel',
  21.         callback: function ( btn, modal, event ) {
  22.           //You can access to the mocal data here
  23.           var modal_data = modal.data.some_data;
  24.         }
  25.       }
  26.     ],
  27.     beforeOpen: function( modal ){
  28.       //You can cancel the modal show event by returning false
  29.     },
  30.     afterOpen: function( modal ){
  31.       //Executed after show event
  32.     },
  33.     beforeClose: function( modal ){
  34.       //You can cancel the hide event by returning false
  35.     },
  36.     afterClose: function( modal ){
  37.       //Executed after hide event
  38.     }
  39. });

或者你可以通过下面的方法来设置默认的配置参数:

  1. $.fn.niftyModal('setDefaults',{
  2.     overlaySelector: '.modal-overlay',
  3.     closeSelector: '.modal-close',
  4.     classAddAfterOpen: 'modal-show',
  5. });

与 Bootstrap 结合使用:

该插件可以和 Bootstrap 结合使用,你只需要引入 jquery.niftymodals.bootstrap.css 文件。

  1. <link rel="stylesheet" type="text/css" href="[your path]/dist/jquery.niftymodals.bootstrap.css">

这个 css 样式表包含了对原生 Bootstrap 模态窗口组件的一些重写样式,例如:modal-header、modal-content 和 modal-footer 等。
jquery-niftymodals 模态窗口插件的 github 地址为:https://github.com/foxythemes/jquery-niftymodals

带炫酷 CSS3 过渡动画 jQuery 模态窗口插件

已有 439 人购买
查看演示升级 VIP立刻购买

演示地址 下载地址
收藏
(0)

发表回复

热销模板

Ashade - 作品展示摄影相册WordPress汉化主题
LensNews

本站承接 WordPress / PbootCMS / DedeCMS 等
系统建站、仿站、开发、定制等业务!