请教高手

moplusplus 2008-04-10 12:37:38
效果如下:
http://www.jscode.cn/jscode/code_360804725.htm
请问如果我想让弹出的小窗口的位置在 点击我试试看 这几个字的右边,紧靠 点击我试试看 这几个字,请教高手该如何修改?
...全文
30 点赞 收藏 4
写回复
4 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
hookee 2008-04-10

<!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" lang="zh-CN">

<head>
<!-- meta data -->
<meta http-equiv="Content-Language" content="zh-cn" />
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta name="robots" content="all" />
<meta name="author" content="在远方@www.jscode.cn" />
<meta name="Copyright" content="Copyright (c) jscode.cn" />
<link rel="icon" href="/favicon.ico" type="image/x-icon" media="screen" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" media="screen" />
<meta name="description" content="网页特效观止" />
<meta name="keywords" content="网页特效,网页特效代码" />
<!-- site title -->
<title>点击弹出窗口层,并且背景变暗渐变---网页特效观止|www.jscode.cn|网页特效代码</title>
<style>
body {font-size:12px;background:#9EC7E7}
img {border:0px}
#msgDiv {
z-index:10001;
width:500px;
height:400px;
background:white;
border:#336699 1px solid;
position:absolute;
left:50%;
top:20%;
font-size:12px;
margin-left:-225px;
display: none;
}
#bgDiv {
display: none;
position: absolute;
top: 0px;
left: 0px;
right:0px;
background-color: #777;
filter:progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75)
opacity: 0.6;
}
</style>
<script type="text/javascript">
function showDetail() { //在远方www.jscode.cn
//背景
var bgObj=document.getElementById("bgDiv");
bgObj.style.width = document.body.offsetWidth + "px";
bgObj.style.height = screen.height + "px";

//定义窗口
var obj = event.srcElement;
var lt = getAbsPos(obj,"left") + obj.innerHTML.length*16;
var tp = getAbsPos(obj,"top") -16;
var msgObj=document.getElementById("msgDiv");
// msgObj.style.marginTop = -75 + document.documentElement.scrollTop + "px";
msgObj.style.left = lt;
msgObj.style.top = tp;
msgObj.style.margin = 0;

//关闭
document.getElementById("msgShut").onclick = function(){
bgObj.style.display = msgObj.style.display = "none";
}
msgObj.style.display = bgObj.style.display = "block";
msgDetail.innerHTML="<p align=center>小窗口里的内容</p><p align=center><A href=http://www.jscode.cn><FONT color=#0000ff>网页特效观止</FONT></A></p>"
}
function getAbsPos( oId, tl ) {
var o = ((typeof oId) == 'String') ? document.getElementById( oId ) : oId;
var val = 0;
while ( o.tagName.toLowerCase() != "body") {
val += (tl == 'top') ? parseInt( o.offsetTop ) : parseInt( o.offsetLeft );;
o = o.parentNode;
}
return val;
}
</script>
</head>

<body>

<div id="msgDiv">
<div id="msgShut">
关闭</div>
<div id="msgDetail">
</div>
</div>
<div id="bgDiv">
</div>
<p> </p>
<p><a href="#" onClick="showDetail()">点击我试试看</a></p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p>更多网页特效代码尽在 <a href="http://www.jscode.cn/">网页特效观止</a></p>

</body>

</html>

回复
mantti 2008-04-10

z-index:10001;
width:500px;
height:400px;
background:white;
border:#336699 1px solid;
position:absolute;
left:50%; //把这句修改一下,修改成10%或者别的什么100px,20px之类的,就可以修改窗口的水平位置
top:20%;
font-size:12px;
margin-left:-225px;
display: none;

回复
mantti 2008-04-10

z-index:10001;
width:500px;
height:400px;
background:white;
border:#336699 1px solid;
position:absolute;
left:50%; //把这句修改一下,修改成10%或者别的什么100px,20px之类的,就可以修改窗口的水平位置
top:20%;
font-size:12px;
margin-left:-225px;
display: none;
回复
itzhiren 2008-04-10
<!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" lang="zh-CN">

<head>
<!-- meta data -->
<meta http-equiv="Content-Language" content="zh-cn" />
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta name="robots" content="all" />
<meta name="author" content="在远方@#" />
<meta name="Copyright" content="Copyright (c) #" />
<link rel="icon" href="/favicon.ico" type="image/x-icon" media="screen" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" media="screen" />
<meta name="description" content="网页特效观止" />
<meta name="keywords" content="网页特效,网页特效代码" />
<!-- site title -->
<title>点击弹出窗口层,并且背景变暗渐变---网页特效观止|#|网页特效代码</title>
<style>
body {font-size:12px;background:#9EC7E7}
img {border:0px}
#msgDiv {
z-index:10001;
width:500px;
height:400px;
background:white;
border:#336699 1px solid;
position:absolute;
left:31%;
top:20%;
font-size:12px;
margin-left:-225px;
display: none;
}
#bgDiv {
display: none;
position: absolute;
top: 0px;
left: 0px;
right:0px;
background-color: #777;
filter:progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75)
opacity: 0.6;
}
</style>
<script type="text/javascript">
function showDetail() { //在远方www.jscode.cn
//定义窗口
var msgObj=document.getElementById("msgDiv");
msgObj.style.marginTop = -75 + document.documentElement.scrollTop + "px";

//关闭
document.getElementById("msgShut").onclick = function(){
msgObj.style.display = "none";
}
msgObj.style.display = "block";
msgDetail.innerHTML="<p align=center>小窗口里的内容</p><p align=center><A href=#><FONT color=#0000ff>网页特效观止</FONT></A></p>"
}
</script>
</head>

<body>

<div id="msgDiv">
<div id="msgShut">
关闭</div>
<div id="msgDetail">
</div>
</div>
<div id="bgDiv">
</div>
<p> </p>
<p><a href="#" onClick="showDetail()">点击我试试看</a></p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p>更多网页特效代码尽在 <a href="#">网页特效观止</a></p>

</body>

</html>
回复
相关推荐
发帖
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
帖子事件
创建了帖子
2008-04-10 12:37
社区公告
暂无公告