分享一个提示框
来源:互联网 发布:家暴 知乎 编辑:程序博客网 时间:2024/06/03 21:28
/** * desc:提示框 alertLayer({text: '测试'}); * author:274501366@qq.com * date:2016-06-13 * */function alertLayer(options) { var settings = $.extend({ time: 3000, text: "请注意啦", msgClass: "popup_tips", alertType: "al_warn", Ismask: true, maskClass: "mask" /* 遮罩样式class */ }, options); if(!$("." + settings.msgClass).length) { var span = document.createElement("div"); var popHtml = '<div class="popup_header">' +'<div class="popup_headtop clearfix"><i class="popup_headleft ficon fleft"></i><i class="popup_headmidlle fleft"></i><i class="popup_headright ficon fleft"></i></div>' +'<div class="popup_headcon"><a class="popup_close ficon fright" title="关闭"></a><span class="popup_title">温馨提示</span></div>' +'</div>' +'<div class="popup_body">' +'<p class="popup_body_tips">'+ settings.text +'</p>' +'</div>' +'<div class="popup_tottom clearfix"><i class="popup_botleft ficon fleft"></i><i class="popup_botmiddle fleft"></i><i class="popup_botright ficon fleft"></i></div>'; $(span).html(popHtml).addClass(settings.msgClass).appendTo("body"); var windowWidth, windowHeight, popWidth, popHeight, top, left; windowWidth = $(window).width(); /* 窗口宽度 */ windowHeight = $(window).height(); /* 窗口高度 */ popWidth = $(span).width(); popHeight = $(span).height(); top = (windowHeight - popHeight) / 2; left = (windowWidth - popWidth) / 2; $(span).css({top: top + "px", left: left + "px", "z-index": "9992"}).fadeIn(400); if(settings.Ismask) { var div = document.createElement("div"); $(div).addClass(settings.maskClass).appendTo("body").css({width: windowWidth + "px", height: $(document).height() + "px"}); $(window).resize(function() { bodyWidth = $(document).width(); /* body宽度 */ bodyHeight = $(document).height(); /* body高度 */ $(div).css({width: bodyWidth + "px", height: bodyHeight + "px"}); }); $(window).scroll(function() { bodyWidth = $(document).width(); /* body宽度 */ bodyHeight = $(document).height(); /* body高度 */ $(div).css({width: bodyWidth + "px", height: bodyHeight + "px"}) }); } /*setTimeout(function() { $(span).fadeOut(400).remove(); settings.Ismask ? $(div).remove() : ''; }, settings.time);*/ $(span).find(".popup_close").click(function(){ $(span).fadeOut(400).remove(); settings.Ismask ? $(div).remove() : ''; }); }}
<pre name="code" class="css">/**弹窗样式star*/.fleft{ float:left; }.fright{ float:right; }.mask{ position: absolute; width: 100%; height: 100%; top: 0; left: 0; background: rgb(0,0,0); opacity:.2; z-index: 1000; filter: Alpha(Opacity=20); }.alertMsg{ display: block; padding: 30px; max-width: 450px; position: absolute; text-align: center; font-size: 14px; background: #fff; border-radius: 4px; z-index: 902; color: #f0271d; }.ficon { background-image: url(../images/icons.png); background-repeat: no-repeat;}.popup, .popup_tips{ width: 462px; z-index: 999; position: fixed; }.popup_header{ width:100%; }.popup_headtop, .popup_tottom{ width: 100%; height: 3px; }.popup_headtop i, .popup_tottom i{ display: block; *display: inline; height: 3px; }.popup_headleft{ width: 2px; background-position: -302px -62px; }.popup_headmidlle{ width: 458px; background:#6397ea; }.popup_headright{ width: 2px; background-position: -305px -62px; }.popup_headcon{ height: 50px; padding:0 12px 0 18px; background:#6397ea; line-height: 48px; }.popup_title{ font-size: 18px; color: #fff; }.popup_close{ display: block; width: 27px; height: 26px; background-position: -169px -213px; margin-top: 11px; cursor: pointer; }.popup_body{ padding: 30px; background: #fff; }.popup_botleft{ width: 2px; background-position: -302px -66px; }.popup_tottom .popup_botmiddle{ width: 458px; height: 2px; background: #fff; }.popup_botright{ width: 2px; background-position: -305px -66px; }.popup_body_tips{ width: 80%; margin:0 auto; height: 100px; padding-top: 20px; font-size: 16px; color: #3b3b3b; text-align: center; }.popup_body_btnp{ text-align: center; margin:30px auto 0; }.popup_btn{ display: inline-block; *display: inline; *zoom:1; width: 137px; height: 38px; line-height: 38px; text-align: center; background-position: 0 -248px; font-size: 18px; color: #fff; }/**弹窗样式end*/希望大家多多交流,多多分享。qq:274501366
0 0
- 分享一个提示框
- 分享一个纯CSS开发的气泡式提示框
- 分享一个气泡提示框:JS+CSS练习
- vue弹出一个内容,弹出分享提示
- 分享一个智能提示搜索控件的实现
- 分享一个智能提示搜索控件的实现
- 一个title提示框
- 分享微信端判断,覆盖提示框显示
- 一个按钮的提示框
- 一个通用的提示框
- 写一个百度提示框
- 一个简单的提示框
- 分享一个纯CSS在线气泡提示生成工具 - CSS ARROW PLEASE!
- 分享一个基于jQuery,backbone.js和underscore.js的消息提示框架 - Backbone.Notifier
- Android UI设计: 分享一个仿QQ聊天消息提示可以拖拉气泡
- Android UI设计: 分享一个仿QQ聊天消息提示可以拖拉气泡
- 分享朋友圈提示使用app分享功能
- iOS-顶部提示框源码分享,在顶部弹出提示框
- Linux共享内存的内核实现
- 选择排序----堆排序----java实现
- C语言入门(三)菜单设置
- java web项目部署方式
- iOS 开发笔记
- 分享一个提示框
- Android中Recyclerview使用1----实现ListView,GridView,瀑布流样式
- eclipse 报错 Export aborted because fatal lint errors were found.
- 自定义导航栏的,使用左侧滑动
- springMVC是实现前台带进度条文件上传
- uboot下mkconfig脚本具体含义
- 深度学习——研究方向
- Hive函数大全
- WebView详解