js 控制DIV与另一个DIV重合
<divid=mydivstyle="width:100px;height:100px;border:1pxsolidgreen;"></div><script>crea...
<div id=mydiv style="width:100px;height:100px;border:1px solid green;"></div>
<script>
creatDiv=..;
让 creatDiv 与 mydiv 完全重合
</sript> 展开
<script>
creatDiv=..;
让 creatDiv 与 mydiv 完全重合
</sript> 展开
2个回答
展开全部
<html>
<head>
<title></title>
</head>
<body>
<div id="main">
<div id=mydiv style="width:100px;height:100px;border:1px solid green;"></div>
</div>
<script>
var main = document.getElementById("main");
var mydiv = document.getElementById("mydiv");
var create = document.createElement("div");
main.appendChild(create);
with(main.style){
position = "relative";
}
var w = mydiv.style.width;
var h = mydiv.style.height;
with(create.style){
position = "absolute";
top = 0;
left = 0;
width = w;
height = h;
border = "1px solid #ff0000";
}
</script>
</body>
</html>
在IE6 和 FF下正常 ,如有问题 Hi me!!
<head>
<title></title>
</head>
<body>
<div id="main">
<div id=mydiv style="width:100px;height:100px;border:1px solid green;"></div>
</div>
<script>
var main = document.getElementById("main");
var mydiv = document.getElementById("mydiv");
var create = document.createElement("div");
main.appendChild(create);
with(main.style){
position = "relative";
}
var w = mydiv.style.width;
var h = mydiv.style.height;
with(create.style){
position = "absolute";
top = 0;
left = 0;
width = w;
height = h;
border = "1px solid #ff0000";
}
</script>
</body>
</html>
在IE6 和 FF下正常 ,如有问题 Hi me!!
展开全部
<html>
<head>
<title></title>
</head>
<body>
<div
id="main">
<div
id=mydiv
style="width:100px;height:100px;border:1px
solid
green;"></div>
</div>
<script>
var
main
=
document.getElementById("main");
var
mydiv
=
document.getElementById("mydiv");
var
create
=
document.createElement("div");
main.appendChild(create);
with(main.style){
position
=
"relative";
}
var
w
=
mydiv.style.width;
var
h
=
mydiv.style.height;
with(create.style){
position
=
"absolute";
top
=
0;
left
=
0;
width
=
w;
height
=
h;
border
=
"1px
solid
#ff0000";
}
</script>
</body>
</html>
在IE6
和
FF下正常
,如有问题
Hi
me!!
<head>
<title></title>
</head>
<body>
<div
id="main">
<div
id=mydiv
style="width:100px;height:100px;border:1px
solid
green;"></div>
</div>
<script>
var
main
=
document.getElementById("main");
var
mydiv
=
document.getElementById("mydiv");
var
create
=
document.createElement("div");
main.appendChild(create);
with(main.style){
position
=
"relative";
}
var
w
=
mydiv.style.width;
var
h
=
mydiv.style.height;
with(create.style){
position
=
"absolute";
top
=
0;
left
=
0;
width
=
w;
height
=
h;
border
=
"1px
solid
#ff0000";
}
</script>
</body>
</html>
在IE6
和
FF下正常
,如有问题
Hi
me!!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询