html 中div的位置问题

luyinglply 2013-09-06 01:39:19
我写了个菜单,然后菜单里有button 、label,但是他们的位置不正确,麻烦帮忙看下
<!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">
<title>窗体1</title>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script src="jquery-1.4.2.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
var name = "";
$("#menu ul li a").each(function () {
$(this).click(function () {
name = $(this).attr("title");
$("#div2 div").each(function () {
$(this).attr("style", "background-color:" + name + ";display:none;");
if ($(this).attr("id") == name) {
$(this).attr("style", "background-color:" + name + ";");
}
})
});
});
});
</script>
<style>.div1{width:1006px;height:682px;float:left;}</style>
<style type="text/css">
#menu ul li { display:inline; float:left; margin-bottom:20px; }
#menu ul li a { padding:20px;text-decoration: none;}
.main { clear:both;width:10%; height:60px;margin-left:0px;}</style>
</head>
<body>

<div class="div1">


<div id=control5 style="position:absolute;top:153px;left:57px">


<div id="menu">
<ul>
<li ><a href="#" title=页面1>页面1</a></li>
<li ><a href="#" title=页面2>页面2</a></li>
</ul>
</div>

<div id="div2" class="main" >

<div id=页面1 style="display:none">
<div id=页面1 style="position:absolute;left:12px;Top:26px;">
<input type="button" name=按钮2 value=按钮2 style="width:75px;height:25px" >
</div>
<div id=页面1 style="position:absolute;left:50px;Top:10px;">
<input type="text" name=编辑框2 style="width:121px;height:19px"/>
</div>

</div>

</div>

</div>



</div>

</body>
</html>
...全文
204 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
luyinglply 2013-09-06
  • 打赏
  • 举报
回复
还是不对。。。
tony4geek 2013-09-06
  • 打赏
  • 举报
回复
<div id=页面1 style="position:absolute;left:50px;Top:10px;margin-top: 10px;margin-left: 50px;">
luyinglply 2013-09-06
  • 打赏
  • 举报
回复
你看 button 与edit在一个层内,应该按照各自的left,top 进行定位,但是现在它都在一起,也就是left、top没起作用。 <div id=页面1 style="display:none"> <div id=页面1 style="position:absolute;left:12px;Top:26px;"> <input type="button" name=按钮2 value=按钮2 style="width:75px;height:25px" > </div> <div id=页面1 style="position:absolute;left:50px;Top:10px;"> <input type="text" name=编辑框2 style="width:121px;height:19px"/> </div>
tony4geek 2013-09-06
  • 打赏
  • 举报
回复
具体怎么样才正确。

61,115

社区成员

发帖
与我相关
我的任务
社区描述
层叠样式表(英文全称:Cascading Style Sheets)是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言。
社区管理员
  • HTML(CSS)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧