大神能解释下么

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

  <head>

  <meta http-equiv="content-type" content="text/html; charset=utf-8">

  <meta name="generator" content="PSPad editor, www.pspad.com">

  <title></title>

  <style>

  #container {

    width:1000px;

    background:gray;

    }

   #header {

    height:120px;

    background:orange;

    }

    #main {

    height:600px;

    background:green;

    }

    #lside {

    height:600px;

    width:700px;

    background:pink;

    float:left;

    }

    #rside {

    height:600px;

    width:300px;

    background:purple;

    float:right;

    }

    #footer {

    height:120px;

    background:blue;

    }

    </style>

  </head>

  <body>

       <div id = "container">

       <div id = "header"></div>

       <div id = "main">

       <div id = "lside"></div>

       <div id = "rside"></div>

       </div>

       <div id = "footer"></div>

       </div>

  </body>

</html>

为什么去掉header时最上面没有灰色填充 container不包括header么

慕粉1471134825
浏览 1967回答 3
3回答

WingMeng

HTML结构没错,很可能是body默认的margin: 8px导致的,你加上这句样式:body {margin: 0;}
打开App,查看更多内容
随时随地看视频慕课网APP