仿腾讯微博的一个弹出框 v0.1 beta
仿腾讯微博的一个弹出框 v0.1 beta
代码写的不太好,新手请大家海涵,只为博君一笑,勿放在心上。
写在这里留作纪念,也许以后用的到。
效果

CSS

.prompt{
position: absolute;
background: white;
width: 330px;
height: 187px;
display: none;
}
.prompt i{
background: url(../images/ui_i_pic_.png) no-repeat;
width: 32px;
height: 32px;
display: block;
float: left;
margin-right: 10px;
}
.prompt span{
font-size: 14px;
font-weight: bold;
line-height: 32px;
}
.prompt .ok{
background: url(../images/button_03.gif) no-repeat;
color: white;
clear: left;
}
.prompt .cancel{
background: url(../images/button_05.gif) no-repeat;
color: black;
margin-left: 10px;
}
.prompt a{
float: left;
font-size: 12px;
width: 65px;
height: 23px;
display: block;
line-height: 23px;
text-decoration: none;
text-align: center;
}
.prompt .buttons{
margin: 50px 0 0 42px;
}
.prompt b{
position: absolute;
background: black;
opacity: 0.2;
}
.prompt .left{
left: 0;
top: 4px;
height: 179px;
width: 4px;
}
.prompt .top{
top: 0;
height: 4px;
width: 330px;
}
.prompt .right{
right: 0;
top: 4px;
height: 179px;
width: 4px;
}
.prompt .bottom{
bottom: 0;
height: 4px;
width: 330px;
}
.prompt .warning{
background-position: -34px 0;
}
.prompt .success{
background-position: 0 0;
}
.prompt .information{
background-position: -68px 0;
}
.prompt .inner{
margin: 40px 60px 40px;
}

JS

(function ($) {
$.extend({
prompt: function (text, type, ok, cancel) {
var prompt = $('<div class="prompt"><b class="left"></b><b class="right"></b><b class="top"></b><b class="bottom"></b><div class="inner"><i class=" + type + "></i><span>' + text + '</span><div class="buttons"><a class="ok" href="#">是</a><a class="cancel" href="#">否</a></div></div></div>').appendTo('body');
prompt.css({
left: ($(window).width() - prompt.width()) / 2,
top: ($(window).height() - prompt.height()) / 2
}).show();
prompt.find('.ok').bind('click', ok);
prompt.find('.cancel').bind('click', cancel);
return prompt;
}
});
})(jQuery);

HTML和使用方法

<!DOCTYPE html> <html lang="en">
<head>
<meta charset="utf-8" />
<title></title> <script type="text/javascript" src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
<script type="text/javascript" src="js/prompt.t.qq.com.min.js"></script> <link rel="stylesheet" type="text/css" href="css/prompt.t.qq.com.min.css" /> <style type="text/css"> body{
margin: 0;
padding: 0;
} .content{
width: 960px;
margin: 0 auto;
margin-top: 200px;
} </style> <script type="text/javascript"> $(function () { $('a').click(function () {
var prompt = $.prompt('您确定放弃本次编辑?', 'information', function () { alert('您点击了确定按钮'); }, function () {
prompt.fadeOut(function () {
prompt.remove();
});
});
}); }); </script> </head>
<body> <div class="content"> <textarea style="width: 500px;height: 200px;"></textarea>
<a href="#" style="display: block;">点击我出现窗口</a> </div> </body>
</html>

参数1 显示内容
参数2 图标类型 information success warning
参数3 点击[是]的事件
参数4 点击[否]的事件
代码在此,供上,希望能帮助大家.
IE的透明度使用filter:alpha(opacity=xx),我没写IE的直接用了chrome的opacity,有空我再加上,希望您使用的时候要注意兼容IE。
仿腾讯微博的一个弹出框 v0.1 beta的更多相关文章
- Bootstrap方法为页面添加一个弹出框
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- vue.js 利用组件之间通讯,写一个弹出框例子
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- android中怎么把自己须要的app启动图标集中到一个弹出框中
先看效果图 这个是我们自己的apk点击之后的效果 下边是布局文件 activity_main.xml主布局文件 <LinearLayout xmlns:android="http:// ...
- 移动web:Tips消息弹出框
在web开发中经常会用到像alert这样的弹出消息,每个浏览器自带的消息弹出框都不相同.为了统一外观,实现自定义的功能,动手写一个弹出框插件. 对弹出框的实现要求如下: 1. 仿照IOS系统弹出外观 ...
- 弹出框优化实例(alert和confirm)
在项目过程中会遇到需要使用自己定义的弹出框的情况.以前用过ymprompt,但是它太复杂而且不好自己操控.所以自己写了一个弹出框实例. 主要有两类弹出框alert和confirm.基于jQuery a ...
- Bootstrap 弹出框和警告框插件
一.弹出框 弹出框即点击一个元素弹出一个包含标题和内容的容器. //基本用法 <button class="btn btn-lg btn-danger" type=" ...
- Android 学习笔记之AndBase框架学习(二) 使用封装好的进度框,Toast框,弹出框,确认框...
PS:渐渐明白,在实验室呆三年都不如在企业呆一年... 学习内容: 1.使用AbActivity内部封装的方法实现进度框,Toast框,弹出框,确认框... AndBase中AbActivity封 ...
- android自定义弹出框样式实现
前言: 做项目时,感觉Android自带的弹出框样式比较丑,很多应用都是自己做的弹出框,这里也试着自己做了一个. 废话不说先上图片: 实现机制 1.先自定义一个弹出框的样式 2.自己实现CustomD ...
- 练习PopupWindow弹出框之实现界面加载的时候显示弹出框到指定的view下面--两种延迟方法
今天在练习PopupWindow弹出框的时候,打算在界面加载的时候将弹出框展现出来并显示在指定的view下面. 初步方法是直接在OnResume方法里面直接执行showPopupWindows方法. ...
随机推荐
- NSString 常用分类
#pragma mark 清空字符串中的空白字符 - (NSString *)trimString { return [self stringByTrimmingCharactersInSet:[NS ...
- Yii Framework2.0开发教程(4)在yii中定义全局变量
在yii中定义全局变量最好的地方是入口脚本处.也就是web目录中的index.php文件 比如我们在defined('YII_ENV') or define('YII_ENV', 'dev');后写上 ...
- s2sh三大框架整合过程(仅供参考)
三大框架顾名思义就是非常有名的Struts2 ,Hibernate,Spring, 框架整合的方法很多,现在我写一个非常简单的整合过程,相信大家一看就会! 这里使用的struts-2.2.1.1.hi ...
- Android在真机调试的设置方法
1. 设置android手机为USB调试模式.步骤: menu---> 设置 ---> 应用程序 ---> 开发 , 选择[USB调试] 2. 用USB连接手机和电脑,并确保成功.步 ...
- PHP中遍历stdclass object 及 json
原文:PHP中遍历stdclass object 及 json (从网上找的模拟实例)需要操作的数据: $test=Array ( [0] => stdClass Object ( [tags] ...
- SQL点滴8—the account is currently locked out. The system administrator can unlock it.
原文:SQL点滴8-the account is currently locked out. The system administrator can unlock it. 今天遇到的问题比较有意思. ...
- NHibernate中使用memcache二级缓存
在NHibernate中使用memcache二级缓存 一.Windows下安装Memcache 1. 下载 http://jehiah.cz/projects/memcached-win32/ ...
- php调用webservice报错Class 'SoapClient' not found
原文:php调用webservice报错Class 'SoapClient' not found php在调用webservice时,报告如下类似错误: ( ! ) Fatal error: Clas ...
- ACM-简单的主题Factorial——poj1401
明出处:http://blog.csdn.net/lttree Factorial Time Limit: 1500MS Memory Limit: 65536K Total Submission ...
- NET Socket服务编程
smark https://github.com/IKende/ .NET Socket服务编程之-高效连接接入编 在.NET上编写网络服务深入都有2,3年了,而这些时间时如何在.NET里实现网络服务 ...