如何对页面正文进行边距html?

问题描述

| 我用了以下
<body topmargin=\"0\" leftmargin=\"0\" rightmargin=\"0\">
仅适用于IE6。我希望它可以与Firefox和Opera一起使用。 我尝试了以下操作:
<style type=\"text/css\">
.header {
    width: 100%;
    background-color: #3B5998;
    height: 35px;
    margin-top:0;
}
.style1 {
    margin-right: 38px;
}
.style2 {
    width: 100%;
    background-color: #3B5998;
    height: 35px;
}


</style>
<div dir=\"rtl\" class=\"style2\" style=\"width: 100%\">
<p align=\"center\"style=\"width: 92px; height: 32px; font-family: Arial,Helvetica,sans-serif; font-size: 20px; color: #EFF1F6;\" class=\"style1\"></p>
</div>

</body>
    

解决方法

首先,您可以使用:
<body style=\"margin:0;padding:0\">
学习了有关CSS的知识后,可以将其更改为:
body {margin:0;padding:0}
在您的样式表中。     ,是的,在这里CSS入门不会受到伤害,因此您可以做两件事: 1-在html的标签中,您可以打开一个样式标签,如下所示:
<style type=\"text/css\">
  body {
   margin: 0px;
  }
  /*
   * this is the same as writing
   * body { margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;}
   * I\'m adding px here for clarity sake but the unit is not really needed if you have 0
   * look into em,pt and % for other unit types 
   * the rules are always clockwise: top,right,bottom,left
  */
</style>
2-以上内容仅适用于嵌入了此代码的页面,因此,如果要在10个文件中重复使用此代码,则必须将其复制到所有10个文件中,并且要进行更改假设有5px的边距,则必须打开所有这些文件并进行编辑。这就是为什么使用外部样式表是前端编码中的黄金法则的原因。 因此,将主体声明保存在一个名为style.css的单独文件中,然后将其添加到html中:
<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\"/>
现在,您可以将其放入所有将从这些样式中受益的页面中,并且只要需要更改它们,您只需要在一个地方进行。希望能帮助到你。干杯     ,HTML为内容,CSS为样式
<body style=\'margin-top:0;margin-left:0;margin-right:0;\'>
    ,您需要使用CSS。这就是现代网页设计完成工作的方式。 这是基本的CSS演练。 您的html文件如下所示: (非常简单的html)
    <html>
    <head>
    <link rel=\"stylesheet\" type=\"text/css\" href=\"mystyle.css\" />
    </head>
    <body>
    </body>
    <html>
您的CSS文件(mystyle.css)如下所示:
body 
{
 margin-top:0px;
 margin-left:0px;
 margin-right:0px;

}
    ,希望对您有所帮助。
html{
     background-color:green;
}

body {
    position:relative; 
    left:200px;    
    background-color:red;
}
div{
    position:relative;  
    left:100px;
    width:100px;
    height:100px;
    background-color:blue;
}
http://jsfiddle.net/6M6ZQ/     ,尝试使用CSS。
body {
   margin: 0 0 auto 0;
}
该顺序从顶部开始是顺时针方向,所以ѭ12。     ,
<body topmargin=\"0\" leftmargin=\"0\" rightmargin=\"0\">
我不确定您从哪里读到的,但这是设置CSS样式内联的公认方法是:
<body style=\"margin-top: 0px; margin-left: 0px; margin-right: 0px;\">
并带有样式表:
body
{
  margin-top: 0px;
  margin-left: 0px;
  margin-right: 0px;
}
    ,我会说:(简单的零会起作用,0px是零;))
<body style=\"margin: 0;\">
但也许某些东西会覆盖您的CSS。 (在您之后分配不同的样式;) 如果您使用Firefox,请查看firebug插件。 在Chrome浏览器中-右键单击页面,然后在菜单中选择\“检查元素\”。在元素树中找到BODY并检查其属性。