html 中div的位置问题
我写了个菜单,然后菜单里有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>
<!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>
...全文
相关推荐
如何让DIV固定在页面的某个位置而不随着滚动条随意滚动
为了解决这个问题,我们可以使用JavaScript来实现DIV的固定位置。在讨论这个问题之前,让我们先回顾一下HTML的基本结构。
vue项目中在可编辑div光标位置插入内容的实现代码
以上就是在Vue项目中实现可编辑div光标位置插入内容的基本步骤。需要注意的是,由于浏览器之间的兼容性问题,可能需要对不同的浏览器进行适配。
javascrip 浮动在屏幕固定位置的div
总结来说,"javascrip 浮动在屏幕固定位置的div"是通过结合HTML、CSS和JavaScript来实现的一种网页设计技术,用于创建始终在用户屏幕某个位置显示的交互元素。
23.(leaflet篇)leaflet叠加html(leaflet叠加div元素).zip
Leaflet使用SVG或Canvas来绘制地图,但并不直接支持HTML元素的插入。不过,我们可以通过在地图上创建一个固定位置的div,然后将HTML内容添加到这个div中,来达到叠加HTML的效果。
canvas 绘图时位置偏离的问题解决
在使用HTML5的canvas元素进行图形绘制时,经常会遇到绘图位置偏离预期的问题。这个问题通常发生在canvas元素的尺寸被设置得不合理时。我们来详细探讨一下相关的知识点。


