简体   繁体   English

如何消除顶部多余的空格?

[英]How can I get rid of extra white space at the top?

it's me again, as im trying to learn I got to a frustrating part. 我又是我了,因为我想学习的过程让我感到沮丧。 First theres extra space enter image description here at the top with every browser. 首先,每个浏览器在顶部都有多余的空间,在顶部输入图像描述 I alredy tried body {overflow:auto;} in the css but aparently only works till certain point and desapeared the extra space at the right but not at the top. 我试过在CSS中尝试body {overflow:auto;} ,但显然只在特定点之前起作用,并且消失了右边而不是顶部的多余空间。 I already tried resetting the margins and paddings in my css but with no luck. 我已经尝试过重置CSS中的边距和填充,但是没有运气。 Also for some reason the cover image isn't showing. 同样由于某种原因,没有显示封面图像。 Any sugestions? 有任何建议吗?

You can check the prokect here: https://github.com/flukec777/MarsLandpage 您可以在这里检查项目: https//github.com/flukec777/MarsLandpage

You need to remove .col class from <div class="col span-1-of-2 bg"> on line 26 . 您需要从line 26 <div class="col span-1-of-2 bg">删除.col类。

Editing the .col port in css file can have effect in your other tags as well, as you have used that class elsewhere in the document too. 在css文件中编辑.col端口也会对其他标签产生影响,因为您也在文档的其他位置使用了该类。

The extra space is being caused by the .col class in Grid.css. 多余的空间是由Grid.css中的.col类引起的。 The .col class contains: .col类包含:

.col {
      display: block;
      float:left;
      margin: 1% 0 1% 1.6%;
     }

One solution to this problem is to remove or edit the margin property located in the .col class. 解决此问题的一种方法是删除或编辑.col类中的margin属性。 You can do this dynamically through JavaScript, of course. 当然,您可以通过JavaScript动态地执行此操作。

The reason behind extra space on the top is the div with class .col.span-1-of-2.bg inside header we can remove this space using margin . 顶部上方多余空间的原因是div,其标题内包含类.col.span-1-of-2.bg,我们可以使用margin删除此空间。

html, body {
    overflow: initial;
}

header .col.span-1-of-2.bg {
    margin-top: 0;
}

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

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