`
cqh520llr
  • 浏览: 520174 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
文章分类
社区版块
存档分类
最新评论

好看的弹出框

 
阅读更多

好看的弹出框

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>弹出层效果</title>
<style type="text/css">
html, body {height:100%;}
body, h2, p {margin:0px;padding:0px; font-size:12px;}
body {font-size:12px; text-align:center; }
.alert_backg {width:100%;height:100%;top:0px;left:0px;position:absolute;background:#000;opacity:0;filter:alpha(opacity:0)}
.alert_frame {width:340px;height:120px;top:50%;left:50%;position:absolute;display:inline;margin:-60px 0 0 -170px;opacity:0;filter:alpha(opacity:0)}
.alert_frame .top_l {width:5px;height:5px;float:left;overflow:hidden;background:url(/jscss/demoimg/201109/corner.png) no-repeat;}
.alert_frame .top_c {width:330px;height:5px;float:left;overflow:hidden;background:url(/jscss/demoimg/201109/wraplayer.png) repeat-x;}
.alert_frame .top_r {width:5px;height:5px;float:left;overflow:hidden;background:url(/jscss/demoimg/201109/corner.png) no-repeat -5px 0;}
.alert_frame .con {width:100%;height:110px;float:left;overflow:hidden;}
.alert_frame .con_l {width:5px;height:100%;float:left;overflow:hidden;background:url(/jscss/demoimg/201109/wraplayer.png) repeat-y;}
.alert_frame .con_c {width:330px;height:100%;float:left;overflow:hidden;background:#fff;}
.alert_frame .con_r {width:5px;height:100%;float:left;overflow:hidden;background:url(/jscss/demoimg/201109/wraplayer.png) repeat-y;}
.alert_frame .bot_l {width:5px;height:5px;float:left;overflow:hidden;background:url(/jscss/demoimg/201109/corner.png) no-repeat 0 -5px;}
.alert_frame .bot_c {width:330px;height:5px;float:left;overflow:hidden;background:url(/jscss/demoimg/201109/wraplayer.png) repeat-x;}
.alert_frame .bot_r {width:5px;height:5px;float:left;overflow:hidden;background:url(/jscss/demoimg/201109/corner.png) no-repeat -5px -5px;}
.alert_frame .alert_tit {width:328px;height:27px;float:left;color:#000;line-height:27px;border:1px solid #fff;background:url(/jscss/demoimg/201109/alert_tit_bg.jpg) repeat-x;}
.alert_frame .alert_tit h2 {float:left;text-indent:10px;font-size:14px;font-weight:bold;font-family:"\u5FAE\u8F6F\u96C5\u9ED1";}
.alert_frame .alert_tit em {width:8px;height:7px;overflow:hidden;float:right;cursor:pointer;background:url(/jscss/demoimg/201109/gnbimgs.gif) no-repeat;display:inline;margin:10px 10px 0 0;}
.alert_frame .alert_tit em.hove {background:url(/jscss/demoimg/201109/gnbimgs.gif) no-repeat -8px 0;}
.alert_frame .alert_con {width:330px;height:81px;float:left;border-top:1px solid #e5e5e5;}
.size {width:100%;height:45px;text-align:center;line-height:45px;color:#000;}
.but {width:100%;height:22px;text-align:center;line-height:22px;}
.button {width:55px;height:22px;text-align:center;line-height:22px;color:#fff;background:url(/jscss/demoimg/201109/but.jpg) no-repeat;border:none;display:inline;margin:0 8px;cursor:pointer;}
.title {width:800px;height:35px;color:#fff;line-height:35px;font-family:Verdana;font-weight:bold;text-align:left;margin:20px auto 0 auto;font-size:24px;}
.table {width:800px;height:auto;overflow:hidden;margin:0 auto 20px auto;font-size:12px;border-top:1px solid #ddd;border-left:1px solid #ddd;background:#fff;}
.table ul {margin:0px;padding:0px;float:left;list-style-type:none;}
.table li {width:159px;height:30px;float:left;color:#3e3e3e;text-indent:10px;text-align:left;line-height:30px;font-family:Verdana,"微软雅黑";	border-right:1px solid #ddd;border-bottom:1px solid #ddd;}
.table li.td {color:#fff;font-size:14px;font-family:"微软雅黑";font-weight:bold;background:#424242;}
.table li.tit {width:479px;}
.table .tr {width:800px;height:30px;float:left;text-indent:10px;text-align:left;line-height:30px;font-size:14px;font-family:Verdana;border-right:1px solid #ddd;border-bottom:1px solid #ddd;}
.table .tr a {color:#ff6600;text-decoration:none;}
.table .tr a:hover {text-decoration:underline;}
</style>
<script type="text/javascript">
function $(id){
	return typeof id === "string" ? document.getElementById(id) : id;
}
function $$(oParent, elem){
	return (oParent || document).getElementsByTagName(elem);
}
function $$$(oParent, sClass){
	var aElem = $$(oParent, '*');
	var aClass = [];
	var i = 0;
	for(i=0;i<aElem.length;i++)if(aElem[i].className == sClass)aClass.push(aElem[i]);
	return aClass;
}
function Alert(){
	this.initialize.apply(this, arguments);
}
Object.extend = function(destination, source){
    for (var property in source) {
        destination[property] = source[property];
    }
    return destination;
};
Alert.prototype = {
	initialize : function(obj, frame, onEnd){
		if($(obj)){
			var _this = this;
			this.obj = $(obj);
			this.frame = frame;
			this.oEve(onEnd);
			this.oTitle = this.onEnd.title;
			this.oContent = this.onEnd.content;
			this.iWidth = this.onEnd.width;
			this.iHeight = this.onEnd.height;
			this.iTop = this.onEnd.top;
			this.iLeft = this.onEnd.left;
			this.iFixed = this.onEnd.fixed;
			this.iClose = this.onEnd.close;
			this.obj.onclick = function(){_this.create(),_this.backg();};
			window.onresize = function(){_this.backg();};
		}
	},
	create : function(){
		this.oDiv = document.createElement('div');
		this.oAlert_backg = document.createElement('div');
		this.oAlert_frame = document.createElement('div');
		this.oTop_l = document.createElement('div');
		this.oTop_c = document.createElement('div');
		this.oTop_r = document.createElement('div');
		this.oCon = document.createElement('div');
		this.oCon_l = document.createElement('div');
		this.oCon_c = document.createElement('div');
		this.oCon_r = document.createElement('div');
		this.oBot_l = document.createElement('div');
		this.oBot_c = document.createElement('div');
		this.oBot_r = document.createElement('div');
		this.oDiv.id = this.frame;
		this.oAlert_backg.className = 'alert_backg';
		this.oAlert_frame.className = 'alert_frame';
		this.oTop_l.className = 'top_l';
		this.oTop_c.className = 'top_c';
		this.oTop_r.className = 'top_r';
		this.oCon.className = 'con';
		this.oCon_l.className = 'con_l';
		this.oCon_c.className = 'con_c';
		this.oCon_r.className = 'con_r';
		this.oBot_l.className = 'bot_l';
		this.oBot_c.className = 'bot_c';
		this.oBot_r.className = 'bot_r';
		document.body.appendChild(this.oDiv);
		this.box = $(this.frame);
		this.box.appendChild(this.oAlert_backg);
		this.box.appendChild(this.oAlert_frame);
		this.oFra = $$$(this.box, 'alert_frame')[0];
		this.oFra.appendChild(this.oTop_l);
		this.oFra.appendChild(this.oTop_c);
		this.oFra.appendChild(this.oTop_r);
		this.oFra.appendChild(this.oCon);
		this.oFra.appendChild(this.oBot_l);
		this.oFra.appendChild(this.oBot_c);
		this.oFra.appendChild(this.oBot_r);
		this.oCone = $$$(this.box, 'con')[0];
		this.oCone.appendChild(this.oCon_l);
		this.oCone.appendChild(this.oCon_c);
		this.oCone.appendChild(this.oCon_r);
		this.tit = $(this.frame);
		this.con = $$$(this.tit, 'con_c')[0];
		this.oAlert_tit = document.createElement('div');
		this.oAlert_con = document.createElement('div');
		this.oH2 = document.createElement('h2');
		this.oAlert_tit.className = 'alert_tit';
		this.oAlert_con.className = 'alert_con';
		if(this.oTitle != ""){
			this.con.appendChild(this.oAlert_tit);
			this.con.appendChild(this.oAlert_con);
			this.oAlert_tit = $$$(this.tit, 'alert_tit')[0];
			this.oH2.innerHTML = this.oTitle;
			this.oAlert_tit.appendChild(this.oH2);
		}
		this.content();
		this.width();
		this.height();
		this.top();
		this.left();
		this.fixed();
		this.close();
		this.Top = this.oFra.offsetTop;
		this.oFra.style.top = (this.Top - 40) +'px';
		this.oFra.style.marginTop = 0;
		this.sMove(this.oFra, {top:this.Top, opacity:100});
		this.sMove(this.oBackg, {opacity:50});
	},
	oEve: function(onEnd){
        this.onEnd = {};
        Object.extend(this.onEnd, onEnd || {});
    },
	content : function(){
		this.conent = $$$(this.tit, 'alert_con')[0];
		this.conent == undefined ? this.con.innerHTML = this.oContent : this.conent.innerHTML = this.oContent;
		this.oButton = $$(this.tit, 'button');
		var i = 0;
		var _this = this;
		for(i=0;i<this.oButton.length;i++)this.oButton[i].onclick = function(){_this.em.onclick()};
	},
	width : function(){
		this.oBackg = $$$(this.tit, 'alert_backg')[0];
		this.oFrame = $$$(this.tit, 'alert_frame')[0];
		this.oCon = $$$(this.oFrame, 'con')[0];
		this.oTop_c = $$$(this.oFrame, 'top_c')[0];
		this.oCon_c = $$$(this.oFrame, 'con_c')[0];
		this.oBot_c = $$$(this.oFrame, 'bot_c')[0];
		this.oAlert_tit = $$$(this.oFrame, 'alert_tit')[0];
		this.oAlert_con = $$$(this.oFrame, 'alert_con')[0];
		if(this.iWidth != ""){
			this.oFrame.style.width = parseInt(this.iWidth) +'px';
			this.oFrame.style.marginLeft = -parseInt(this.iWidth) / 2 +'px';
			this.oTop_c.style.width = parseInt(this.iWidth) - 10 +'px';
			this.oCon_c.style.width = parseInt(this.iWidth) - 10 +'px';
			this.oBot_c.style.width = parseInt(this.iWidth) - 10 +'px';
			this.oAlert_tit.style.width = parseInt(this.iWidth) - 12 +'px';
			this.oAlert_con.style.width = parseInt(this.iWidth) - 10 +'px';
		}
	},
	height : function(){
		if(this.iHeight != ""){
			this.oFrame.style.height = parseInt(this.iHeight) +'px';
			this.oFrame.style.marginTop = -parseInt(this.iHeight) / 2 +'px';
			this.oCon.style.height = parseInt(this.iHeight) - 10 +'px';
			this.oAlert_con.style.height = parseInt(this.iHeight) - 40 +'px';
		}
	},
	top : function(){
		if(this.iTop != "")this.oFrame.style.top = parseInt(this.iTop) +'px',this.oFrame.style.marginTop = 0;
	},
	left : function(){
		if(this.iLeft != "")this.oFrame.style.left = parseInt(this.iLeft) +'px',this.oFrame.style.marginLeft = 0;
	},
	backg : function(){
		this.oScrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight;
		this.oScrollWidth = document.documentElement.scrollWidth || document.body.scrollWidth;
		this.oBackg.style.width = document.documentElement.clientWidth + (this.oScrollWidth - document.documentElement.clientWidth) +'px'
		this.oBackg.style.height = document.documentElement.clientHeight + (this.oScrollHeight - document.documentElement.clientHeight) +'px'
	},
	fixed : function(){
		if(this.iFixed == "fixed"){
			var _this = this;
			this.oFrame.style.position = 'fixed';
			this.oAlert_tit.style.cursor = 'move';
			this.oAlert_tit.onmousedown = function(e){
				var _thisE = this;
				this.oEvent = e || event;
				this.X = this.oEvent.clientX - _this.oFrame.offsetLeft;
				this.Y = this.oEvent.clientY - _this.oFrame.offsetTop;
				document.onmousemove = function(e){
					this.oEvent = e || event;
					this.L = this.oEvent.clientX - _thisE.X;
					this.T = this.oEvent.clientY - _thisE.Y;
					if(this.L < 0){
						this.L = 0;
					}else if(this.L > document.documentElement.clientWidth - _this.oFrame.offsetWidth){
						this.L = document.documentElement.clientWidth - _this.oFrame.offsetWidth
					}
					if(this.T < 0){
						this.T = 0;
					}else if(this.T > document.documentElement.clientHeight - _this.oFrame.offsetHeight){
						this.T = document.documentElement.clientHeight - _this.oFrame.offsetHeight;
					}
					_this.oFrame.style.left = this.L + 'px';
					_this.oFrame.style.top = this.T + 'px';
					_this.oFrame.style.margin = 0;
					return false;
				}
				document.onmouseup = function(){
					document.onmouseup = null;
					document.onmousemove = null;
				};
				return false;
				
			};
			if(this.oFrame){
				if(!-[1,] && !window.XMLHttpRequest){
					document.documentElement.style.textOverflow = "ellipsis";
					this.oFrame.style.position = "absolute";
					this.oFrame.style.setExpression("top", "eval(documentElement.scrollTop + " + this.oFrame.offsetTop + ') + "px"');
				}
			}
		}
	},
	close : function(){
		if(this.iClose == "close" && this.oTitle != ""){
			var _this = this;
			this.clos = $$$(this.tit, 'alert_tit')[0];
			var oEm = document.createElement('em');
			this.clos.appendChild(oEm);
			this.em = $$(this.tit, 'em')[0];
			this.em.onmouseover = function(){_this.em.className = 'hove';};
			this.em.onmouseout = function(){_this.em.className = '';};
			this.em.onclick = function(){
				_this.sMove(_this.oFra, {top:(_this.Top - 40), opacity:0},function(){
					document.body.removeChild(_this.em.parentNode.parentNode.parentNode.parentNode.parentNode);
				});
				_this.sMove(_this.oBackg, {opacity:0});
			}
		}
	},
	getStyle : function(obj, attr)
	{
		return obj.currentStyle?obj.currentStyle[attr]:getComputedStyle(obj, false)[attr];
	},
	sMove : function(obj, json, onEnd){
		var _this = this;
		clearInterval(obj.timer);
		obj.timer = setInterval(function(){
			_this.dMove(obj, json, onEnd);
		},30);
	},
	dMove : function(obj, json, onEnd){
		this.attr = '';
		this.bStop = true;
		
		for(this.attr in json){
			this.iCur = 0;			
			this.attr == 'opacity' ? this.iCur = parseInt(parseFloat(this.getStyle(obj, this.attr))*100) : this.iCur = parseInt(this.getStyle(obj, this.attr));
			this.iSpeed = (json[this.attr] - this.iCur) / 7;
			this.iSpeed = this.iSpeed > 0 ? Math.ceil(this.iSpeed) : Math.floor(this.iSpeed);			
			if(json[this.attr] != this.iCur)this.bStop = false;
			if(this.attr == 'opacity'){
				obj.style.filter = 'alpha(opacity:' + (this.iCur + this.iSpeed) +')';
				obj.style.opacity = (this.iCur + this.iSpeed ) / 100;
			}else{
				obj.style[this.attr] = this.iCur + this.iSpeed + 'px';
			}
		}
		if(this.bStop){
			clearInterval(obj.timer);			
			if(onEnd)onEnd();
		}
	}
};
window.onload = function(){
	new Alert('but', 'box', {
		title : '提示内容',
		content : '<div class="size">确定不在关注新浪微博?</div><div class="but"><button class="button">确定</button><button class="button">取消</button></div>',
		width : '',
		height : '',
		top : '',
		left : '',
		fixed : '',
		close : 'close'
	});
};
</script>
</head>
<body style="height:950px;">
<div class="title">API</div>
<div class="table">
	<ul>
    	<li class="td">属性</li>
        <li class="td">默认值</li>
        <li class="tit td">说明</li>
        <li>ButId</li>
        <li>but</li>
        <li class="tit">点击按钮Id(必选)</li>
        <li>ElementId</li>
        <li>box</li>
        <li class="tit">弹出层Id(必选)</li>
        <li>title</li>
        <li>提示信息</li>
        <li class="tit">提示层标题(可选)</li>
        <li>content</li>
        <li>自行编辑</li>
        <li class="tit">提示层内容(可选)</li>
        <li>width</li>
        <li>340px</li>
        <li class="tit">提示层宽度(可选)</li>
        <li>height</li>
        <li>120px</li>
        <li class="tit">提示层高度(可选)</li>
        <li>top</li>
        <li>绝对居中</li>
        <li class="tit">提示层上间距(可选)</li>
        <li>left</li>
        <li>绝对居中</li>
        <li class="tit">提示层上间距(可选)</li>
        <li>fixed</li>
        <li>相对定位</li>
        <li class="tit">跟谁滚动条绝对定位/是否拖拽(fixed:'fixed')(可选)</li>
        <li>close</li>
        <li>close</li>
        <li class="tit">是否显示关闭按钮(close:'close')(可选)</li>
    </ul>
    <div class="tr"><a href="javascript:;" id="but">Examples</a></div>
</div>
</body>
</html>
分享到:
评论

相关推荐

    Android:动画实现精美的弹出框(仿易信)

    在Android开发中,创建引人注目的用户界面是至关重要的,而弹出框作为与用户交互的一种常见方式,其设计和实现方式直接影响到用户体验。本篇文章将深入探讨如何使用动画来实现一个精美的弹出框,类似易信应用中的...

    jquery弹出框样式

    总结来说,创建好看的jQuery弹出框样式涉及HTML结构设计、CSS样式定制以及jQuery事件处理。通过这些技术,我们可以实现交互性强且视觉效果出色的弹出框,从而提高网站或应用的用户满意度。实践过程中,不断调整和...

    js 精美弹出框 alert

    在JavaScript编程中,"js精美弹出框alert"是指通过自定义的方式,创建美观且功能丰富的弹出警告对话框,以替代系统默认的简单且样式单一的`alert()`函数。通常,开发者会使用CSS和JavaScript库来实现这种效果,以...

    超级漂亮的js弹出框效果

    当我们谈论“超级漂亮的js弹出框效果”时,我们通常是指利用JavaScript实现的对话框或者提示框,这些弹出框不仅具备基本功能,还通过美观的设计提升了用户体验。在本文中,我们将深入探讨如何使用JavaScript创建具有...

    纯js漂亮各种弹出框

    "纯js漂亮各种弹出框"这个主题聚焦于如何利用JavaScript创建美观且功能丰富的弹出提示框和对话框。这些功能通常用于通知用户、获取用户输入或者展示详细信息,提升用户体验。 1. **基本弹出框**: JavaScript提供...

    最好看的弹出框 前端页面开发需要的

    标题中的“最好看的弹出框”指的是前端页面开发中的一种用户体验优化技术,通常涉及到对话框、提示框或者模态窗口的设计。这类弹出框在网页中起到信息提示、用户交互或确认操作的作用,设计得美观且易于理解,能够...

    js弹出框 好看

    "js弹出框 好看"这个标题和描述提示我们,我们将讨论如何使用JavaScript创建美观且实用的弹出框。 在网页设计中,弹出框是一种常见的交互元素,它们可以用来显示警告、确认信息,或者提供额外的输入空间。...

    html5 css3简单的遮罩弹出框动态效果

    3. **背景透明度(Opacity)**:利用`opacity`属性,我们可以创建一个半透明的遮罩层,覆盖整个页面,让用户聚焦于弹出框。 4. **过渡效果(Transition)**:通过设置`transition`,弹出框在显示和隐藏时可以平滑地...

    jquery右下角弹出框

    标题“jquery右下角弹出框”指的是利用jQuery实现一个功能,即在网页的右下角弹出提示或信息框。这种设计常用于通知用户、显示警告或请求确认,是一种常见的用户体验元素。 描述中的“Jquery弹出美丽的框”进一步...

    jquery Dialog 弹出框 很漂亮 实用

    jQuery Dialog 是一个功能强大的弹出框插件,它是 jQuery UI 库的一部分,广泛应用于网页交互设计中,提供美观且可自定义的对话框效果。在实际项目中,它以其高效和易用性受到开发者的喜爱。 Dialog 弹出框的核心...

    C# winform 进度条弹出框

    本文将深入探讨如何在C# Winform中实现一个带有进度条的弹出框,并在任务完成后自动关闭。 首先,让我们了解`ProgressBar`控件的基本用法。在Winform设计界面中,你可以从工具箱中拖拽一个`ProgressBar`控件到窗体...

    alert和confirm弹出框样式美化.zip

    标题“alert和confirm弹出框样式美化.zip”提示我们这个压缩包包含的是关于如何自定义和美化`alert`和`confirm`弹出框的内容,使它们更加符合网页的整体设计风格。 描述中提到,这个资源可以让我们自定义弹出框的...

    漂亮的弹出框

    在ASP.NET开发中,弹出框(Pop-up Window)是一种常用的用户交互元素,它可以在用户进行特定操作时显示额外信息、提示或者功能。"漂亮的弹出框"通常指的是设计美观、用户体验良好的弹出对话框。在本文中,我们将深入...

    html弹出框模板(提示框,确定+取消框)

    html下各种弹出框模板(提示框,确定+取消,确定等)包括调用的js和css文件。实测可用,原生开发。

    一个漂亮的弹出框

    标题中的“一个漂亮的弹出框”可能是指在编程或网页设计中实现的一种用户交互界面元素。弹出框通常用于向用户显示警告、确认信息或获取输入。在IT领域,创建弹出框涉及到前端开发,尤其是JavaScript,CSS以及HTML等...

    简洁漂亮美观的弹出框蓝颜色

    在网页设计和开发中,创建一个简洁、漂亮且美观的弹出框是提升用户体验的关键因素之一。"简洁漂亮美观的弹出框蓝颜色" 主题着重于如何利用蓝色调来设计一个既实用又吸引人的弹出窗口。弹出框通常用于提供提示信息、...

    alert和confirm弹出框样式美化

    然而,这两种弹出框的默认样式通常较为简单,无法满足现代网页设计的美观需求。本教程将介绍如何通过自定义CSS和JavaScript来美化`alert`和`confirm`弹出框,实现更个性化的界面效果,而无需依赖浏览器的默认样式。 ...

    各种风格控件按钮 弹出框 底弹出

    "各种风格控件按钮 弹出框 底弹出"这个主题涉及到的是UI设计中的交互元素,特别是按钮和弹出框的设计技巧和应用。这些元素对于提高用户的操作效率和满意度有着直接影响。 首先,我们来探讨控件按钮。控件按钮是用户...

    ////////////漂亮的弹出框/////////

    在IT行业中,弹出框是一种常见的用户界面元素,它用于向用户提供信息、请求确认或接收输入。"////////////漂亮的弹出框/////////"这个标题暗示我们将讨论关于美化和优化弹出框设计的知识点。在描述中反复提到“弹出...

    前端之好看的通用弹出框

    2. **蒙层**:覆盖在主页面上的半透明层,用于防止用户在弹出框显示时与背景内容交互。 3. **容器**:包含模态框内容的区域,通常具有垂直和水平居中的样式,确保无论屏幕大小如何,内容都能居中显示。 4. **标题**...

Global site tag (gtag.js) - Google Analytics