开发者

How to insert a margin at the right and left of the page?

I want to insert this margin, but I don't know why... I want it to be like Twitter or TwitPic

My CSS:

 body {
        margin: 40px;
        margin-bottom: 50px;
        padding: 0;
        background-color: #edece9;
        font-family: "Lucida Grande", "Bitstream Vera Sans", "Verdana";
        font-size: 13px;
    开发者_Go百科    color: #333;
      }


Assuming a page structure like so:

<!DOCTYPE html>
<html>
  <head>
    <link type="text/css" rel="stylesheet" href="style.css" />
  </head>
  <body>
    <div id="main">
    </div>
  </body>
</html>

Then style.css should look like:

* {margin:0;}
div#main {
  width:800px;
  margin:0 auto;
}


twitter uses a fixed-width div which uses margin-left:auto; and margin-right:auto. this will center the div horizontally


you need to put a div with a fixed with (your desired page width and put its margin:0 auto

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜