关于div 元素定位的问题

sq_shenqian 2010-03-18 11:59:54
我现在有一个页面是在1024*768的下面做的,页面大小是990*750,现在我上面有图片,图片上面有数字显示(在每张图片的左边下角,选中相应的数字在图片位置出现相应的图片,是用div定位的,还有就是网页的右侧中间有一个向上、向下的图像(也是用div定位的),是用来控制网页上下移动的,我做出来后,切换到其它的分辩率,这几个定位的图片全移位了,我要如何定呢
代码我简化了下,网页要表达的效果是这样的
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
<!--
html,body{

margin:0px;
padding:0px;
text-align:center;}
#container{
margin:0 auto;
width:990px;
height:750px;
background:#CCCCCC;
}
#top{

width:990px;
height:200px;
background:#FF0000;}
#left{
width:215px;
float:left;
height:500px;
background:#0099FF;
}
#three_n1 {
position:absolute;
width:17px;
height:16px;
z-index:1;
left: 229px;
top: 269px;
border:1px solid #CCC;
background-color:#CCC;
}
#three_n2 {
position:absolute;
width:17px;
height:17px;
z-index:2;
left:253px;
top: 269px;
border:1px solid #CCC;
background-color:#CCC;
}
#three_n3 {
position:absolute;
width:17px;
height:17px;
z-index:3;
left: 279px;
top: 270px;
border:1px solid #CCC;
background-color:#CCC;
}

#right{
width:775px;
float:right;
background:#CCFF33;
height:500px;}
#up {
position:absolute;
width:22px;
height:19px;
z-index:4;
left: 955px;
top: 358px;
}
#down {
position:absolute;
width:22px;
height:19px;
z-index:4;
left: 955px;
top: 385px;
}
#footer{

clear:both;
width:990px;
background:#0000FF;
height:50px;}
-->
</style>
</head>

<body>
<div id="container">
<div id="top"></div>
<div id="left"></div>
<div id="right">
<div align="left"><img src="image/img.jpg" width="273" height="95" />
<div id="three_n3">3</div>
<div id="three_n2">2</div>
<div id="three_n1">1</div>
</div>
</div>

<div id="footer"></div>
<div id="up"><img src="image/top.jpg" /></div>
<div id="down"><img src="image/down.jpg" /></div>
</div>
</body>
</html>
...全文
118 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
ddcatlee 2010-03-18
  • 打赏
  • 举报
回复
父元素设定相对定位
sq_shenqian 2010-03-18
  • 打赏
  • 举报
回复
急啊,我在线等
sq_shenqian 2010-03-18
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 sq_shenqian 的回复:]
引用 3 楼 sq_shenqian 的回复:
引用 2 楼 ddcatlee 的回复:
父元素设定相对定位

为什么在ie 和火狐中定位出来的效果不一样呢

大家看看,有些地方效果不一样,尤其是地四个图片上的数字差异最大,怎么改,改哪里
这是html代码,引用1.css

HTML code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML……
[/Quote]
还有就是浏览器检测那里提示有“浮动下降问题”,如何解决啊
sq_shenqian 2010-03-18
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 sq_shenqian 的回复:]
引用 2 楼 ddcatlee 的回复:
父元素设定相对定位

为什么在ie 和火狐中定位出来的效果不一样呢
[/Quote]
大家看看,有些地方效果不一样,尤其是地四个图片上的数字差异最大,怎么改,改哪里
这是html代码,引用1.css

<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>盟途TEST</title>
<link href="1.css" rel="stylesheet" type="text/css" />

</head>
<body>
<div id="container">
<div id="header">
<div id="globlelink"> <span><a href="#">Home</a></span>/ <span><a href="#">Home</a></span>/ <span><a href="#">Home/</a></span> <span><a href="#">Home/</a></span> <span><a href="#">Home</a></span>
<input value="Search site:" size="20" maxlength="30" />
<img src="image/serch.jpg" /> </div>
</div>
<div id="sidebar"> <img src="image/mt_r2_c1.jpg" /><br />
<ul>
<li>Edelstahl Massiv</li>
<li>Edelstahl gefaltet</li>
<li >Titan Massiv</li>
<li >Milanaise Bänder</li>
</ul>
<img src="image/mt_r6_c1.jpg" /><br />
<ul>
<li>Edelstahl Massiv</li>
<li>Edelstahl gefaltet</li>
<li >Titan Massiv</li>
<li>Milanaise Bänder</li>
</ul>
<img src="image/mt_r6_c1.jpg" /><br />
<ul>
<li>Edelstahl Massiv</li>
<li>Edelstahl gefaltet</li>
<li >Titan Massiv</li>
<li>Milanaise Bänder</li>
</ul>
<img src="image/mt_r6_c1.jpg" /><br />
<ul>
<li>Edelstahl Massiv</li>
<li>Edelstahl gefaltet</li>
<li>Titan Massiv</li>
<li class="li_btm">Milanaise Bänder</li>
</ul>
</div>
<div id="content">
<div id="cont_one" class="cont_one">
<img src="image/img_p_r3_c4.gif" />
<div id="one_n3">3</div>
<div id="one_n2">2</div>
<div id="one_n1">1</div>
<p>Massiv Edelstahl,Piloten-Band,Art. RT-753</p>
<p class="p_c" >Herzlich Willkommen! Wer liefert was?“ ist die marktführende Lieferantensuc<br />
fürs Business-to-Business. „</p>
<table class="tab_cs">
<tr>
<th>Material</th>
<th>Breite</th>
<th>Dicke</th>
<th>Länge</th>
<th>Schliesse</th>
<th>Gewicht</th>
<th>Ab</th>
</tr>
<tr>
<td>Edelstahl,Massiv</td>
<td>8,20,24,26mm</td>
<td>2,5mm</td>
<td>250mm</td>
<td>Faltschliesse</td>
<td>120g</td>
<td>100.St.</td>
</tr>
</table>
</div>
<div class="hr_c"><hr /></div>
<!--one-->
<div id="cont_two" class="cont_one">
<img src="image/img.jpg">
<div id="two_n3">3</div>
<div id="two_n2">2</div>
<div id="two_n1">1</div>
<p>Massiv Edelstahl,Piloten-Band,Art. RT-753</p>
<p class="p_c" >Herzlich Willkommen! Wer liefert was?“ ist die marktführende Lieferantensuc<br />
fürs Business-to-Business. „</p>
<table class="tab_cs">
<tr>
<th>Material</th>
<th>Breite</th>
<th>Dicke</th>
<th>Länge</th>
<th>Schliesse</th>
<th>Gewicht</th>
<th>Ab</th>
</tr>
<tr>
<td>Edelstahl,Massiv</td>
<td>8,20,24,26mm</td>
<td>2,5mm</td>
<td>250mm</td>
<td>Faltschliesse</td>
<td>120g</td>
<td>100.St.</td>
</tr>
</table>
</div>
<div class="hr_c"><hr /></div>


<!--part two-->
<div id="cont_three" class="cont_one">
<img src="image/img_p_r3_c5.jpg" />
<div id="three_n3">3</div>
<div id="three_n2">2</div>
<div id="three_n1">1</div>
<p>Massiv Edelstahl,Piloten-Band,Art. RT-753</p>
<p class="p_c" >Herzlich Willkommen! Wer liefert was?“ ist die marktführende Lieferantensuc<br />
fürs Business-to-Business. „</p>
<table class="tab_cs">
<tr>
<th>Material</th>
<th>Breite</th>
<th>Dicke</th>
<th>Länge</th>
<th>Schliesse</th>
<th>Gewicht</th>
<th>Ab</th>
</tr>
<tr>
<td>Edelstahl,Massiv</td>
<td>8,20,24,26mm</td>
<td>2,5mm</td>
<td>250mm</td>
<td>Faltschliesse</td>
<td>120g</td>
<td>100.St.</td>
</tr>
</table>
</div>
<div class="hr_c"><hr /></div><!--part three-->
<div id="cont_four" class="cont_one">
<img src="image/img_p_r3_c6.jpg"/>

<p>Massiv Edelstahl,Piloten-Band,Art. RT-753</p>
<p class="p_c" >Herzlich Willkommen! Wer liefert was?“ ist die marktführende Lieferantensuc<br />
fürs Business-to-Business. „</p>
<table class="tab_cs">
<tr>
<th>Material</th>
<th>Breite</th>
<th>Dicke</th>
<th>Länge</th>
<th>Schliesse</th>
<th>Gewicht</th>
<th>Ab</th>
</tr>
<tr>
<td height="14">Edelstahl,Massiv</td>
<td>8,20,24,26mm</td>
<td>2,5mm</td>
<td>250mm</td>
<td>Faltschliesse</td>
<td>120g</td>
<td>100.St.</td>
</tr>
</table>
</div>
<div></div>
</div>
<div id="footer">
</div>
<div id="four_n3">3</div>
<div id="four_n2">2</div>
<div id="four_n1">1</div>
<div id="up"><img src="image/top.jpg" /></div>
<div id="down"><img src="image/down.jpg" /></div>
</div>

</body>
</html>


这是1.css代码
* {	
margin: 0px;
padding: 0px;
border-top-width: 0px;
border-right-width: 0px;
border-bottom-width: 0px;
border-left-width: 0px;
}
html, body {
text-align:center;
font:12px/12px Arial, Helvetica, sans-serif;

}
#container {
margin:0 auto;
background-image:url(image/bck.jpg);
width:990px;
height:750px;
position:relative;
}
#header {
background:url(image/header.jpg) no-repeat;
width:990px;
height:120px;
}
#sidebar {
float:left;
margin-top:0px;
width:215px;
height:600px;
}
#sidebar img {
margin-bottom:0px;
height:39px;
width:215px;
}
#sidebar br {
display:none;
}
#sidebar ul {
margin-top:0px;
list-style-type:none;
padding:0px;
}
#sidebar ul li {
margin:0px;
background:url(image/mt_r4_c1.jpg) no-repeat;
height:28px;
line-height:28px;

color:#7ea1b1;
font-family: Arial, Helvetica, sans-serif;
font-size: 13px;
font-style: italic;
}

#sidebar ul li.li_btm {
background:url(image/mt_r8_c1.jpg) no-repeat;
height:24px;
line-height:24px;
}
#content {
background:url(image/mt_r2_c3.jpg) no-repeat top right;
width:775px;
height:600px;
float:right;
margin-bottom:0px;

}
.cont_one {
width:750px;
height:105px;
margin-left:0px;
padding-top:20px;
padding-right:20px;
}
#content .cont_one img {
float:left;
width:273px;
height:95px;
}
#content p {
text-align:left;
margin-left:20px;
font:italic bold 13px/13px Arial, Helvetica, sans-serif;
}
#content p.p_c {
margin-left:20px;
font:normal 12px/24px Arial, Helvetica, sans-serif;
text-align:left;
}
.tab_cs {
margin-top:10px;
margin-left:10px;

border:none;

}
.tab_cs th {
background:url(image/th_bck.jpg);
border:none;

}
.tab_cs td {
background:url(image/td_bck.jpg);
border:none;
height:14px;
}
.hr_c {
width:700px;
margin-right:40px;
}
#one_n1 {
position:absolute;
width:17px;
height:17px;
z-index:1;
left: 239px;
top: 213px;
border:1px solid #CCCCCC;
background-color:#CCCCCC
}
#one_n2 {
position:absolute;
width:17px;
height:17px;
z-index:2;
left: 263px;
top: 213px;
border:1px solid #CCC;
background-color:#CCC;
}
#one_n3 {
position:absolute;
width:17px;
height:17px;
z-index:3;
left: 288px;
top: 213px;
border:1px solid #CCC;
background-color:#CCC;
}
#two_n1 {
position:absolute;
width:17px;
height:17px;
z-index:1;
left: 239px;
top: 355px;
border:1px solid #CCC;
background-color:#CCC;
}
#two_n2 {
position:absolute;
width:17px;
height:17px;
z-index:2;
left:263px;
top: 355px;
border:1px solid #CCC;
background-color:#CCC;
}
#two_n3 {
position:absolute;
width:17px;
height:17px;
z-index:3;
left: 288px;
top: 355px;
border:1px solid #CCC;
background-color:#CCC;
}
#three_n1 {
position:absolute;
width:17px;
height:16px;
z-index:1;
left: 239px;
top: 494px;
border:1px solid #CCC;
background-color:#CCC;
}
#three_n2 {
position:absolute;
width:17px;
height:17px;
z-index:2;
left:263px;
top: 494px;
border:1px solid #CCC;
background-color:#CCC;
}
#three_n3 {
position:absolute;
width:17px;
height:17px;
z-index:3;
left: 288px;
top: 494px;
border:1px solid #CCC;
background-color:#CCC;
}
#four_n1 {
position:absolute;
width:17px;
height:17px;
left: 239px;
top: 648px;
border:1px solid #CCC;
background-color:#CCC;
}

#four_n2 {
position:absolute;
width:17px;
height:17px;

left:263px;
top: 648px;
border:1px solid #CCC;
background-color:#CCC;
}
#four_n3 {
position:absolute;
width:17px;
height:17px;

left: 288px;
top: 648px;
border:1px solid #CCC;
background-color:#CCC;
}

#up {
position:absolute;
width:22px;
height:19px;
left: 945px;
top: 360px;
}
#down {
position:absolute;
width:22px;
height:19px;
left:945px;
top: 380px;
}

#footer {
clear:both;
background:url(image/mt_r9_c1.jpg) no-repeat;
height:30px;
margin-top:0px;
text-align:center;
width:990px;
}
郭大侠_ 2010-03-18
  • 打赏
  • 举报
回复
数字定位那儿已经好了,上下图片的位置你自己参照着修改.

<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
<!--
html,body{

margin:0px;
padding:0px;
text-align:center;}
#container{
margin:0 auto;
width:990px;
height:750px;
background:#CCCCCC;
}
#top{

width:990px;
height:200px;
background:#FF0000;}
#left{
width:215px;
float:left;
height:500px;
background:#0099FF;
}
#three_n1 {
position:relative;
width:17px;
height:17px;
z-index:1;
left: 10px;
top: -67px;
border:1px solid #CCC;
background-color:#CCC;
}
#three_n2 {
position:relative;
width:17px;
height:17px;
z-index:2;
left:40px;
top: -48px;
border:1px solid #CCC;
background-color:#CCC;
}
#three_n3 {
position:relative;
width:17px;
height:17px;
z-index:3;
left: 70px;
top: -29px;
border:1px solid #CCC;
background-color:#CCC;
}

#right{
width:775px;
float:right;
background:#CCFF33;
height:500px;}
#up {
position:absolute;
width:22px;
height:19px;
z-index:4;
left: 955px;
top: 358px;
}
#down {
position:absolute;
width:22px;
height:19px;
z-index:4;
left: 955px;
top: 385px;
}
#footer{
clear:both;
width:990px;
background:#0000FF;
height:50px;
}
-->
</style>
</head>

<body>
<div id="container">
<div id="top"></div>
<div id="left"></div>
<div id="right">
<div align="left">
<img src="image/img.jpg" width="273" height="95" style="display:block;"/>
<div id="three_n3">3</div>
<div id="three_n2">2</div>
<div id="three_n1">1</div>
</div>
</div>

<div id="footer"></div>
<div id="up"><img src="image/top.jpg" /></div>
<div id="down"><img src="image/down.jpg" /></div>
</div>
</body>
</html>

sq_shenqian 2010-03-18
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 ddcatlee 的回复:]
父元素设定相对定位
[/Quote]
为什么在ie 和火狐中定位出来的效果不一样呢

61,110

社区成员

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

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