+ -
当前位置:首页 → 问答吧 → 边距混乱的问题

边距混乱的问题

时间:2010-09-28

来源:互联网


<!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> body,ul,li{margin:0;padding:0;} .div1{ background:red;height:500px;} .div2{ background:green;margin-top:50px;} li{ width:100px;height:30px;margin-top:10px; background:#ccc;} </style> </head> <body> <div class="div1"> <div class="div2"> <ul> <li>sdffffff</li> </ul> </div> </div> </body> </html>
 提示:您可以先修改部分代码再运行
经常遇到这种问题。按代码看,应该是div2距离div1是50个像素,可现在成了div1到顶部50个像素,这是为什么

[ 本帖最后由 wpf5400 于 2010-9-28 14:42 编辑 ]

作者: wpf5400   发布时间: 2010-09-28

难道大家都没有碰到过?

作者: wpf5400   发布时间: 2010-09-28