怪了,设置float:left和right效果不一样

daixiulin 2010-12-21 10:16:24
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml/DTD/xhtml-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title></title>
<style type="text/css">
<!--
body,img,ul,li,div,form,input,span,object{margin:0;padding:0;}
#container {width: 920px;margin: 0px auto;}
#leftcon {
float: left;
width: 230px;
border: 1px solid #CCCCCC;
height:300px;
padding-bottom: 15px;
padding-left: 5px;
}
#rightcon {
float:right; <!--设置left正常-->

width:676px;
border: 1px solid #CCCCCC;
height: 100px;
background-color: #CCCCCC;
}


#footer {border-top:1px solid #339999;text-align: center;}
.clearfloat {clear:both;}

-->
</style>

</head>

<body>
<div id="container">
<!--左边内容-->
<div id="leftcon"></div>
<!--右边内容-->
<div id="rightcon" ></div>
<!--网页底部-->
<div id="footer" class="clearfloat"></div>
</div>

</body>
</html>
...全文
146 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
wszdw142 2010-12-30
  • 打赏
  • 举报
回复
哦,看出来了。。

你设置 float:right; 的时候左右div应该调换下位置,要不会往下跑

<body>
<div id="container">

<div id="rightcon" ></div>

<div id="leftcon"></div>


<div id="footer" class="clearfloat"></div>
</div>
</body>
wszdw142 2010-12-30
  • 打赏
  • 举报
回复
没明白哪里不对劲
daixiulin 2010-12-30
  • 打赏
  • 举报
回复
左右浮动在这种情况下效果应该一样呀
86y 2010-12-21
  • 打赏
  • 举报
回复
你试下在左右两个里面添加两个内容就可以了 !
houtianfu 2010-12-21
  • 打赏
  • 举报
回复
本来就不一样啊
ajccom 2010-12-21
  • 打赏
  • 举报
回复
LZ你怎么了? 本来就应该不一样? 一个左浮动,一个右浮动

61,112

社区成员

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

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