[英]How to get rid of this extra white space for my div?
I create this app with create-react-app cli
and I cannot get rid of these extra white spaces at top, left and right side of my main container. 我使用
create-react-app cli
创建此应用create-react-app cli
,但无法摆脱主容器顶部,左侧和右侧的这些多余空白。 Take a look at the screenshot below. 看一下下面的截图。 I have only one
div
for this app yet and I have the following css for the div. 我只有一个该应用程序的
div
,并且我的div具有以下CSS。
.mainContainer{ display: flex; flex-direction: column; background-color: black; }
What I have tried is setting both margin and padding for 0px, but neither of them works. 我尝试过的是为0px设置边距和填充,但是它们都不起作用。
html, body { margin: 0; padding: 0 }
You can right-click on the page, select Inspect and you will be able to see where this margin/padding is coming from. 您可以在页面上单击鼠标右键,选择“检查”,您将能够看到此边距/填充的来源。 A console will appear, move your mouse over the HTML elements to see a color overlay over the page element.
将出现一个控制台,将鼠标移到HTML元素上以查看page元素上的颜色叠加。 You will be able to see what CSS is doing this and adjust it.
您将能够看到CSS正在执行的操作并进行调整。
I think you will be able to get rid of it by doing this .mainContainer { padding: 0, margin: 0 }
but maybe you will only have to reset the padding or the margin, not both. 我认为您可以通过执行
.mainContainer { padding: 0, margin: 0 }
来摆脱它,但是也许您只需要重置padding或margin即可,而不必同时重置两者。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.