佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 1040|回复: 8

关于div的问题

[复制链接]
发表于 5-12-2010 06:14 PM | 显示全部楼层 |阅读模式
各位高手请帮帮忙,小弟我刚才把content这div放了float: left后就不能置中了,margin有放auto,请问是什么问题??
回复

使用道具 举报


ADVERTISEMENT

发表于 5-12-2010 08:59 PM | 显示全部楼层
float:left 是移去(靠)左边吧
回复

使用道具 举报

 楼主| 发表于 5-12-2010 09:55 PM | 显示全部楼层
回复 2# vampcheah


应该是吧,因为content里有contentL和contentR,因为要把contentL放在左边就用float: left,不过放了之后conten就怎样都弄不去中间了~~
回复

使用道具 举报

发表于 6-12-2010 11:55 AM | 显示全部楼层
有没有漏了放这个:

body {
text-align:center;
}
回复

使用道具 举报

发表于 6-12-2010 04:00 PM | 显示全部楼层
我建议你把code paste在帖里, 不然很难明白
回复

使用道具 举报

 楼主| 发表于 6-12-2010 07:48 PM | 显示全部楼层
回复 4# 小仓


放了也是一样~~
回复

使用道具 举报

Follow Us
 楼主| 发表于 6-12-2010 07:51 PM | 显示全部楼层
这个是css里的
  1. #header {
  2. background-image: url(Untitled-1.jpg);
  3. background-repeat: no-repeat;
  4. height: 208px;
  5. width: 1100px;
  6. margin-right: auto;
  7. margin-left: auto;
  8. }
  9. #content {
  10. background-image: url(Untitled-1-1.jpg);
  11. background-repeat: repeat-y;
  12. width: 1100px;
  13. float: left;
  14. margin-right: auto;
  15. margin-left: auto;
  16. text-align: center;
  17. }
  18. #footer {
  19. height: 50px;
  20. width: 1100px;
  21. background-image: url(Untitled-1-2.jpg);
  22. background-repeat: no-repeat;
  23. clear: left;
  24. margin-right: auto;
  25. margin-left: auto;
  26. }
  27. #contentL {
  28. float: left;
  29. width: 230px;
  30. }
  31. #contentR {
  32. margin-left: 230px;
  33. }#R {
  34. text-align: right;
  35. }
复制代码


这个是html里的

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Untitled Document</title>
  6. <link href="Files/css.css" rel="stylesheet" type="text/css" />
  7. </head>
  8. <body>
  9. <div id="header">
  10.   <div id="R"><br />
  11.     <p><a href="register.php">注册</a>
  12.       <a href="login.php">登入</a>&nbsp;&nbsp;&nbsp;&nbsp;</p>
  13.   </div>
  14. </div>
  15. <div id="content">
  16.   <div id="contentL">
  17.    
  18.   Content for  id "contentL" Goes Here</div>
  19.   <div id="contentR">Content for  id "contentR" Goes Here</div>
  20. Content for  id "content" Goes Here</div>
  21. <div id="footer">Content for  id &quot;footer&quot; Goes Here</div>
  22. </body>
  23. </html>
复制代码
回复

使用道具 举报

发表于 6-12-2010 08:55 PM | 显示全部楼层
把css的line 13去除掉就可以了。

你要把#contentL放在左边就在#contentL里用float: left就够了。
不需要在#content里再加float:left。
回复

使用道具 举报


ADVERTISEMENT

 楼主| 发表于 7-12-2010 05:37 PM | 显示全部楼层
回复 8# 小仓


噢噢~~好的好的~~谢谢你~~
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 17-11-2025 06:30 AM , Processed in 0.141918 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表