Margins White Spaces

I get white space in the left, right and top margins.

However, if I set the background color in the body like this: <body id="SuperMainBlock"> or <body bgcolor="#000066"> it will occupy the whole page --» However this is not a block :P

I'm guessing the white margin spaces are due to the blocks. Is it possible to make div block occupy 100% of the page?

    <style>
.SuperMainBlock {
    position:relative;
    background-color:#006;
    }

.MainBlock {
    display: block;
    position:relative;
    background-color:#FFF;
    visibility: visible;
    height: 500px;
    width: 70%;
    margin-left: auto;
    margin-right: auto;
    border-top-style: dotted;
    border-right-style: dotted;
    border-bottom-style: dotted;
    border-left-style: dotted;
    border-top-color: #000;
    border-right-color: #000;
    border-bottom-color: #000;
    border-left-color: #000;
    padding: 0;
    }
    </style>

    </head>

    <body>

    <div class="SuperMainBlock">
        <div class="MainBlock" id="CenteredBlock">
            <div>
            Header
            </div>  
        </div>
    </div>
    </body>

^ This code makes the white margins.


First of all i think you are getting the white spaces because the browser has its own default spaces set, and you need to reset that. and also yes you can make it take 100%.

 /*edit the mainblock style*/
 .mainblock{ 
 height: 500px;
 width: 100%;
 margin-left:0 auto;
 margin-right:0 auto;
 }

/*now add this to your style to  reset the browser margin and padding*/

  body{
  margin:0;
  padding:0;
  }
链接地址: http://www.djcxy.com/p/89302.html

上一篇: 阻止白色空间修复无效

下一篇: 边距白色空间