相关疑难解决方法(0)

如何删除网页中的上边距?

我在创建的每个网页上都遇到过这个问题.我用来将我的内容放在页面中心的"主容器"div上面总是有一个上边距.我使用的是css样式表,并将正文中的边距和填充设置为0px,并在div中将边距和填充设置为0:

body{
    margin-top: 0px; 
    margin-bottom: 0px; 
    margin-left: 0px; 
    margin-right: 0px;
    padding: 0;
    color: black; 
    font-size: 10pt; 
    font-family: "Trebuchet MS", sans-serif;
    background-color: #E2E2E2;
}

div.mainContainer{
    height: auto; 
    width: 68em;
    background-color: #FFFFFF;
    margin: 0 auto; 
    padding: 0;
}
Run Code Online (Sandbox Code Playgroud)

我已多次在网上看过,但我能看到的就是设置这些边距和填充属性.还有什么我应该做的吗?IE和Firefox中存在边距.

以下是对代码的更全面的了解(它处于创建的开始阶段,因此其中没有太多......)

<!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" />
        <!-- TemplateBeginEditable name="doctitle" -->
        <title></title>
        <!-- TemplateEndEditable -->
        <!-- TemplateBeginEditable name="head" --><!-- TemplateEndEditable -->
        <link href="../Styles/KB_styles1.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
        <div class="mainContainer">
            <p>Here is the …
Run Code Online (Sandbox Code Playgroud)

html css

54
推荐指数
6
解决办法
22万
查看次数

标签 统计

css ×1

html ×1