| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 674 人关注过本帖
标题:偶当斑竹的第一个帖子
只看楼主 加入收藏
linuxpluto
Rank: 4
等 级:贵宾
威 望:13
帖 子:889
专家分:23
注 册:2005-8-14
收藏
 问题点数:0 回复次数:2 
偶当斑竹的第一个帖子

程序代码:
<style type=\"text/css\">
body,td,a {
font-size: 9pt;
color: #330000;
text-decoration: none
}

.aa {
filter:alpha(opacity=70);
}

</style>

<div style=\"position:absolute; left:235px; top:92px;solid;cursor:move\" onmousedown=\"down1(this)\" class=\"aa\" id=plane0>
<table cellpadding=\"0\" border=\"0\" cellspacing=\"1\" width=\"200\" height=\"100\" bgcolor=\"#000000\" >
<tr><td height=\"18\" bgcolor=\"#999999\" ><div align=\"right\">关闭>>><a href=\"#\" onClick=\"clase(0)\">★</a></div></td></tr>
<tr><td bgcolor=\"f4f4f4\">这里是你的文字!!!!!!!!!!!!!!!!!!</td></tr></table></div>

<div style=\"position:absolute;left:350px;top:172px;z-index:1;solid;cursor:move\" id=plane1 onmousedown=\"down1(this)\" class=\"aa\">
<table cellpadding=\"0\" border=\"0\" cellspacing=\"1\" width=\"200\" height=\"100\" bgcolor=\"#000000\" >
<tr><td height=\"18\" bgcolor=\"#999999\" ><div align=\"right\">关闭>>><a href=\"#\" onClick=\"clase(1)\">★</a></div></td></tr>
<tr><td bgcolor=\"f4f4f4\">这里是你的文字!!!!!!!!!!!!!!!!!!</td></tr></table></div>

<script>
//the keyword \"down\" is the flag of mousedown or mouseup
var down=false,divleft,divtop,n;

function clase(x){document.all['plane'+x].style.visibility='hidden'}

//event.clientX and event.clientY 的用法,是当前鼠标的坐标
function down1(m){
n=m;
down=true;
divleft=event.clientX-parseInt(m.style.left);
divtop=event.clientY-parseInt(m.style.top);
//document.write(event.clientX+\"---\"+event.clientY+\"---\"+parseInt(m.style.left)+\"---\"+parseInt(m.style.top)+\"---\"+divleft+\"---\"+divtop);
}

function move(){
if(down)
{
n.style.left=event.clientX-divleft;
n.style.top=event.clientY-divtop;
}
}
</script>
把窗口移到这儿看看吧!

<!--id.style的用法-->
<a href=\"javascript:\" onClick=\"plane0.style.visibility='visible'\">点这儿重新显示0</a>
<a href=\"javascript:\" onClick=\"plane1.style.visibility='visible'\">点这儿重新显示1</a>


第二步:把<body>中的内容改为:
<body bgcolor=\"#fef4d9\" onmousemove=\"move()\" onmouseup=\"down=false\">

搜索更多相关主题的帖子: 斑竹 帖子 
2005-11-02 12:55
linuxpluto
Rank: 4
等 级:贵宾
威 望:13
帖 子:889
专家分:23
注 册:2005-8-14
收藏
得分:0 

这是一个可以移动div代码~~~


吃的比猪还差,干的比驴还累,起的比鸡还早,睡得比小姐还晚,挣得比民工还少,看起来比谁都好——苦命的人.人生短短几十年,不要给自己留下了什么遗憾,想笑就笑,想哭就哭,该爱的时候就去爱,无谓压抑自己
2005-11-02 13:01
开心人
Rank: 1
等 级:新手上路
帖 子:216
专家分:0
注 册:2005-11-1
收藏
得分:0 
啊,好。。。支持!!一定会有用的着的地方

2005-11-02 16:35
快速回复:偶当斑竹的第一个帖子
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018909 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved