渐隐div的一个特效(转)
来源:互联网 发布:新加坡俊知集团 编辑:程序博客网 时间:2024/06/11 09:53
<!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">
* { margin:0px;
padding:0px;}
#cover{position:absolute;top:0;left:0;z-index:100;visibility:hidden;background:#666;}
.shadow{position:absolute;top:0;left:0;z-index:200;visibility:hidden;}
#a_open,a_close{cursor:hand;cursor:pointer; color:red;}
</style>
</head>
<body>
<div id="cover" onClick="DecOpacity();"></div>
<a id="a_open" href="#" onClick="show('cover','contBox');return false;">来点我</a>
<div id="contBox" class="box shadow" style="background:#FFF; width:400px; height:200px; padding:12px 9px;">
这里是内容 <a id="a_close" href="#" onClick="DecOpacity();return false;">关闭</a>
</div>
</body>
</html>
<script type="text/javascript">
function getPageSize(){
var xScroll, yScroll;
if (window.innerHeight && window.scrollMaxY) {
xScroll = window.innerWidth + window.scrollMaxX;
yScroll = window.innerHeight + window.scrollMaxY;
} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
xScroll = document.body.scrollWidth;
yScroll = document.body.scrollHeight;
} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
xScroll = document.body.offsetWidth;
yScroll = document.body.offsetHeight;
}
var windowWidth, windowHeight;
//console.log(self.innerWidth);
//console.log(document.documentElement.clientWidth);
if (self.innerHeight) {// all except Explorer
if(document.documentElement.clientWidth){
windowWidth = document.documentElement.clientWidth;
} else {
windowWidth = self.innerWidth;
}
windowHeight = self.innerHeight;
} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
windowWidth = document.documentElement.clientWidth;
windowHeight = document.documentElement.clientHeight;
} else if (document.body) { // other Explorers
windowWidth = document.body.clientWidth;
windowHeight = document.body.clientHeight;
}
// for small pages with total height less then height of the viewport
if(yScroll < windowHeight){
pageHeight = windowHeight;
} else {
pageHeight = yScroll;
}
//console.log("xScroll " + xScroll)
//console.log("windowWidth " + windowWidth)
// for small pages with total width less then width of the viewport
if(xScroll < windowWidth){
pageWidth = xScroll;
} else {
pageWidth = windowWidth;
}
//console.log("pageWidth " + pageWidth)
arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
return arrayPageSize;
}
var pageS=new Array();
pageS=getPageSize();
var contBox=document.getElementById("contBox");
var cover=document.getElementById("cover");
var tmpAlpha=0.0;
var tmpAlphaN=0.5;
function show(cover,id){
var objCover=document.getElementById(cover);
var objId=document.getElementById(id);
var scrollW = pageS[2];
var scrollH = pageS[3];
var T=(scrollH-objId.offsetHeight)/2+document.body.scrollTop||document.documentElement.scrollTop;
var L=(scrollW-objId.offsetWidth)/2+document.body.scrollLeft||document.documentElement.scrollLeft;
objCover.style.width = scrollW+"px";
objCover.style.height= scrollH+"px";
objCover.style.visibility="visible";
objId.style.visibility="visible";
objId.style.top=T+"px";
objId.style.left=L+"px";
AddOpacity();
}
function hide(cover,id){
var objCover=document.getElementById(cover);
var objId=document.getElementById(id);
objCover.style.visibility="hidden";
objId.style.visibility="hidden";
}
function AddOpacity(){
contBox.style.opacity=tmpAlpha;
contBox.style.filter="alpha(opacity="+tmpAlpha*100+")";
cover.style.opacity=tmpAlpha;
cover.style.filter="alpha(opacity="+tmpAlpha*60+")";
tmpAlpha+=0.05;
if(tmpAlpha>=0.5){
cover.style.opacity = 0.5;
}
if(tmpAlpha>=1){
contBox.style.opacity = 1;
return;}else{
setTimeout("AddOpacity()",20);}
}
function DecOpacity(){
contBox.style.opacity=tmpAlphaN;
contBox.style.filter="alpha(opacity="+tmpAlphaN*100+")";
cover.style.opacity=tmpAlphaN;
cover.style.filter="alpha(opacity="+tmpAlphaN*60+")";
tmpAlphaN-=0.05;
if(tmpAlphaN<=0){
contBox.style.opacity = 0;
contBox.style.visibility="hidden";
cover.style.visibility="hidden";
tmpAlpha=0.0;
tmpAlphaN=0.5;
//clearTimeout()
return;}else{
setTimeout("DecOpacity()",20);}
}
</script>
- 渐隐div的一个特效(转)
- div的移动特效
- Div遮罩 Div居中 Div渐隐渐现
- 纯css3显示隐藏一个div特效
- jquery之超简单的div显示和隐藏特效demo(转)
- jQuery的一个特效
- 渐隐藏的窗口。
- PS图像特效算法——镜像渐隐
- UIImageView自带的一个方法,使图片出现时有渐隐、缓慢出现的效果。
- 一个JavaScript日历表的特效
- 一个MTK的百叶窗特效
- 图片的渐隐渐现特效代码
- 让div左右对齐自适应高度的网页特效(常看)
- Div+Css+Js特效
- DIV伸缩特效
- html Div层的展开与收缩的特效
- 用Jquery模拟的div-css.com中的JS特效
- 网页特效:随滚动条移动的DIV层
- zoj 1140 || poj 1469 Courses
- expr命令
- linux下终端自动登录ssh服务器
- VC++ 6.0的小花招
- 多串匹配-AC自动机
- 渐隐div的一个特效(转)
- c++覆盖,重载,多态
- vb.net与vb的比较
- 基于百度地图API实现的地图形式天气预报【一】
- 32Windows 上Oracle突破1.7G内存限制(一)
- Linux平台Makefile文件的编写基础篇
- 碰撞检测的资源连接
- zoj 1364 || poj 1325 Machine Schedule
- C++面试每日一题之16