简体   繁体   English

不需要的边框,宽约320px

[英]Unwanted border around 320px wide div

I am implementing a page with responsive design. 我正在实现具有响应式设计的页面。 It has a minimum width of 320px. 最小宽度为320px。 When I shrink the screen to 320px wide, there is still a small border around it, which is part of <body> (I have set the background color to red). 当我将屏幕缩小到320px宽时,它周围仍然有一个小边框,这是<body>一部分(我将背景色设置为红色)。

在此处输入图片说明

My CSS is: 我的CSS是:

body {
    background-color: red;
    color: #010109;
}

#newPageTable {
    position: relative;
    min-width: 320px;
    height: 100%;
    margin: 0px auto;
    border: 0px;
    padding: 0px;
    background-color: #FFFFFD;
}

How can I get rid of this border space and make sure my #newPageTable fits exactly within the screen? 如何摆脱边界空间并确保#newPageTable恰好适合屏幕?

Reset the default margin and padding on body as below: 重置默认marginbody padding ,如下所示:

body {
    background-color: red;
    color: #010109;
    margin: 0;
    padding: 0;
}

Doing this should remove that space. 这样做应该删除该空间。

By default some browsers have a margin/padding around the edge of the body. 默认情况下,某些浏览器在主体边缘周围有边距/边距。

Other elements have margin/padding by default too. 默认情况下,其他元素也具有边距/填充。

You can either add a reset to the beggining of you styles, take all margin/padding off by default: 您可以在样式的开头添加重置,默认情况下取消所有边距/边距:

*{
    margin: 0;
    padding: 0;
}

or just apply it to the body tag: 或仅将其应用于body标签:

body{
    margin: 0;
    padding: 0;
}

Some reset style sheets take care of this for you if you use one. 如果您使用一些重置样式表,则可以为您解决这一问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM