如何在网页上创建全角栏?

时间:2021-09-27 07:27:27

I have the following CSS defining the style for a <div> element in my HTML:

我有以下CSS定义HTML中

元素的样式:

#nav {
    float: left;
    clear: both;
    width: 100%;
    height: 50px;
    margin: 0;
    padding: 0;
    background: #3E6ECE;
}

However, for some reason, the page is rendering with a white border as is shown in the image below:

但是,由于某种原因,页面呈现白色边框,如下图所示:

如何在网页上创建全角栏?

Can anyone explain to me what I'm doing wrong? How can I get the blue bar to go the full width of the window?

谁能向我解释我做错了什么?如何让蓝色条移动到窗口的整个宽度?


For reference, my HTML structure is included below:

作为参考,我的HTML结构包含在下面:

<!DOCTYPE html>
<html>
    <head>
        <!-- Header stuff -->
    </head>
    <body>
        <div id='nav'></div>

        <!-- Other body stuff -->

    </body>
</html>

1 个解决方案

#1


try removing padding+margin on the body element

尝试删除body元素上的填充+边距

#1


try removing padding+margin on the body element

尝试删除body元素上的填充+边距