+ -
当前位置:首页 → 问答吧 → 《求助》浮动的问题。。。

《求助》浮动的问题。。。

时间:2008-12-31

来源:互联网

我是一个新手,在学习教程中遇到如下问题,请哪位高手帮忙指点一下,先谢!
问题:现在是做到辅助导航下面的主体部分,引用的样式和开始的导航条那里是一样的左右浮动,但是在这里用相同的方法做出来的结果不一样,向右浮动的DIV没有居中,不明白这是为什么,是哪里错了,为什么上面的可以下面的这个就不可以了呢?
代码如下:
CSS:
/* CSS Document */
html{ height:100%; border: none;}
body{height:100%; width:764px; border: none; padding:0; margin:0; text-align:center; font-size:12px; color:#000000;margin:auto;}
div,ul,li,img{ padding:0; margin:0; border: none;}
ul{ list-style-type:none;}
table,input{ font-size:12px;}
a:link{ color:#A53829; text-decoration: none;}
a:visited{ color:#A53829; text-decoration: none;}
a:hover{ color:#A53829; text-decoration: none; }  /*在这里可以加上position:relative; top:1px;增加一个鼠标经过时活动的效果 */
a:active{ color:#A53829; text-decoration: none;}

.mass{width:762px;}
.center{ text-align: center;}
.clear{ clear:both; visibility:hidden; font-size:0px;}
.border{ border: #FF0000 solid 1px;}  /*solid 1px一像素的描边*/
.boxTop{ margin-Top:5px;}  /*定义两个描边之间的距离,下面的盒子离上面的盒子上边距为5像素*/
--------------------------------------------------------------------
/*导航*/
#nav{}
#nav .left{ float:left; widows:261px;}
#nav .right{ float:right; widows:501}
/*辅助导航*/
#nav2{
background-color:#CCCCCC;
height: 26px;
width: 714px;
padding-left: 50px;
padding-left: 48px !important;
text-align: center;
line-height:26px;
}
#nav2 li{
float:left;
}   
/*主体内容*/
.main_left{ float:left; width:176px;}
.main_right{
float:right;
widows:586px;
}
  
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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>上岛咖啡</title>
<link type="text/css" rel="stylesheet" href="style/index.css" />
<!--外部样式表的引用写法-->
<style type="text/css"><!--
.STYLE1 {color: #FF0000}
-->
</style>
<script type="text/javascript">
<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
</head>
<body>
<div class="border mass">
<!--导航条单元(start)-->
<div id="nav">
  <div class="left"><img src="IMG/LOGO.gif" /></div>
  <div class="right"><img src="IMG/001.gif" border="0" usemap="#Map" />
<map name="Map" id="Map">
  <area shape="rect" coords="79,18,134,44" href="http://www.hzslcm.com" target="_blank" /><area shape="rect" coords="157,19,215,44" href="http://www.hzslcm.com" target="_blank" />
<area shape="rect" coords="238,18,296,43" href="http://www.hzslcm.com" target="_blank" />
<area shape="rect" coords="320,18,379,44" href="http://www.hzslcm.com" target="_blank" />
<area shape="rect" coords="401,19,461,44" href="http://www.hzslcm.com" target="_blank" />
</map>
</div>
<div class="clear"></div><!--这个div 的意思是清除浮动-->
</div>
<!--导航条单元(end)-->
    <!--banner单元(start)-->
    <div clsaa="center"><a href="http://www.hzslcm.com"><img src="IMG/002.gif" width="762" height="150" clsaa="border" /></a></div>
<!--banner单元(end)-->
    <!--"辅助导航"(start)-->
    <a href="http://www.hzslcm.com" target="_blank"><span class="STYLE1">上岛咖啡新版网站正式发布,部分内容正在逐步完善,在此期间点击此处可访问旧版</span></a><img src="IMG/003.gif" alt="辅助导航"  width="315" height="21" align="absmiddle"/>
<div id="nav2">
  <ul>
   <li><a href="#" target="_blank">&nbsp;首页</a>&nbsp;|&nbsp;</li>
   <li>&nbsp;<a href="#">首页</a>&nbsp;|&nbsp;</li>
   <li><a href="#">&nbsp;首页</a>&nbsp;|&nbsp;</li>
      <li><a href="#">&nbsp;首页</a>&nbsp;|&nbsp;</li>
   <li>&nbsp;<a href="#">首页</a>&nbsp;|&nbsp;</li>
   <li>&nbsp;<a href="#">首页</a>&nbsp;</li>
  </ul>
  </div>
</div>
    <!--"辅助导航"(end)-->
<div class="mass border boxTop">
<div class="main_left">neirong</div>
<div class="main_right">neirong</div>
</div>
  
</div>
</body>
</html>

作者: baihe   发布时间: 2008-12-31