页面底部的大空白 space

Big blank space at the bottom of page

我遇到了这个问题,当我在flexbox列中添加背景图片时,我可以看到底部有一个很大的空白space。我试图检查页面,但找不到问题所在。我不知道如何解决这个问题,我想做的是删除空白 space 或者让图片一直下降。

body {
    background-color: rgb(245, 245, 245);
    font-family: 'Roboto', sans-serif;
    padding: 0;
    margin: 0;
    overflow: auto;
}
.main {
    display: flex;
    justify-content: space-evenly;
}
.row {
    flex: 50%;
    padding: 3em;
    padding-left: 15em;
}
.row1 {
    flex: 50%;
}
.row-text-top {
    padding-bottom: 1em;
    font-size: 21px;
}
.row-text-mid {
    padding-bottom: 3em;
    font-size: 16px;
}
.row-text-mid1 {
    font-size: 25px;
    border-left: 5px solid #ff9b7c;
    padding: 0.5em;
    padding-top: 0.1em;
    padding-bottom: 0.1em;
    font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif
}
.row-text-low {
    padding-top: 3em;
}
.row1 {
    background-image: url(earth.jpg);
    background-size: cover;
}
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>City</title>
        <link href="wwd.css" rel="stylesheet" type="text/css">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <script src="index.js"></script>
    </head>
    <body>
        <div class="main">
            <div class="row">
                <h1>Overview</h1>
                <div class="row-text-top">
                    One of the most urgent issues of our time, climate change has widespread                     implications — from the exacerbation of 
                    poverty, to the breakdown of infrastructure, to the loss of                                 environmental, political, economic and social security. 
                    Experts agree that climate change threatens to set back development                         efforts by decades, placing least developed countries 
                    and already-vulnerable populations in an even more precarious position.
                </div>
                <div class="row-text-mid">
                    The latest Intergovernmental Panel on Climate Change (IPCC) Fifth                           Assessment Report (AR5), signed 
                    off by almost 200 nations, concludes with 95% certainty or more that                         humans have caused the majority 
                    of climate change since the 1950s. It predicts global surface                               temperature to continue to rise, along 
                    with increased sea level rise, melting of glaciers and ice sheets,                           acidification of oceans, increase 
                    in the intensity of tropical storms and changes in precipitation                             patterns.
                </div>
                <div class="row-text-mid1">
                    In other words; the science on climate change is clearer than ever, and                     so is the urgency for human action.
                </div>
                <div class="row-text-low">
                    As a global community, we all have a role in developing and implementing                     solutions toward significant 
                    transformation in our development patterns. It requires not only a shift                     in awareness and accountability 
                    for our own individual choices but in a social, political and economic                       shift towards enabling conditions 
                    for these sustainable choices to be made– and in turn, a more just,                         equal and healthy planet.
                </div>
            </div>
            <div class="row1">
            </div>
        </div>
    </body>
</html>

由于没有图片,有点难看,但我会添加一张图片:

问题在这里:

.row {
  flex: 50%;
  padding: 3em;         <---- This line
  padding-left: 15em;
}

您要在行元素周围添加额外的填充,包括底部。删除此填充后,屏幕底部的 space 消失了。

这是一个工作演示:https://codepen.io/Lissy93/pen/yLvBJLe

提示:我建议使用开发者工具,将元素选择器悬停在 space 上,它会准确显示是哪个元素导致的,并显示它是否为(绿色)填充和(橙色)边距。

我在底部没有看到任何 space。我在 linux 上使用 firefox。

body {
    background-color: rgb(245, 245, 245);
    font-family: 'Roboto', sans-serif;
    padding: 0;
    margin: 0;
    overflow: auto;
}
.main {
    display: flex;
    justify-content: space-evenly;
}
.row {
    flex: 50%;
    padding: 3em;
    padding-left: 15em;
}
.row1 {
    flex: 50%;
}
.row-text-top {
    padding-bottom: 1em;
    font-size: 21px;
}
.row-text-mid {
    padding-bottom: 3em;
    font-size: 16px;
}
.row-text-mid1 {
    font-size: 25px;
    border-left: 5px solid #ff9b7c;
    padding: 0.5em;
    padding-top: 0.1em;
    padding-bottom: 0.1em;
    font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif
}
.row-text-low {
    padding-top: 3em;
}
.row1 {
    background-image: url(https://via.placeholder.com/200);
    background-size: cover;
}
        <div class="main">
            <div class="row">
                <h1>Overview</h1>
                <div class="row-text-top">
                    One of the most urgent issues of our time, climate change has widespread                     implications — from the exacerbation of 
                    poverty, to the breakdown of infrastructure, to the loss of                                 environmental, political, economic and social security. 
                    Experts agree that climate change threatens to set back development                         efforts by decades, placing least developed countries 
                    and already-vulnerable populations in an even more precarious position.
                </div>
                <div class="row-text-mid">
                    The latest Intergovernmental Panel on Climate Change (IPCC) Fifth                           Assessment Report (AR5), signed 
                    off by almost 200 nations, concludes with 95% certainty or more that                         humans have caused the majority 
                    of climate change since the 1950s. It predicts global surface                               temperature to continue to rise, along 
                    with increased sea level rise, melting of glaciers and ice sheets,                           acidification of oceans, increase 
                    in the intensity of tropical storms and changes in precipitation                             patterns.
                </div>
                <div class="row-text-mid1">
                    In other words; the science on climate change is clearer than ever, and                     so is the urgency for human action.
                </div>
                <div class="row-text-low">
                    As a global community, we all have a role in developing and implementing                     solutions toward significant 
                    transformation in our development patterns. It requires not only a shift                     in awareness and accountability 
                    for our own individual choices but in a social, political and economic                       shift towards enabling conditions 
                    for these sustainable choices to be made– and in turn, a more just,                         equal and healthy planet.
                </div>
            </div>
            <div class="row1">
            </div>
        </div>

全屏查看此片段。红色虚线边框是 flexbox 的限制。图片下方的 space(根据您的图片)在别处。

body {
  background-color: rgb(245, 245, 245);
  font-family: 'Roboto', sans-serif;
  padding: 0;
  margin: 0;
  overflow: auto;
}

.main {
  display: flex;
  justify-content: space-evenly;
  border: 5px dashed red;
}

.row {
  flex: 50%;
  padding: 3em;
  /* padding-left: 15em;*/
}

.row1 {
  flex: 50%;
}

.row-text-top {
  padding-bottom: 1em;
  font-size: 21px;
}

.row-text-mid {
  padding-bottom: 3em;
  font-size: 16px;
}

.row-text-mid1 {
  font-size: 25px;
  border-left: 5px solid #ff9b7c;
  padding: 0.5em;
  padding-top: 0.1em;
  padding-bottom: 0.1em;
  font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif
}

.row-text-low {
  padding-top: 3em;
}

.row1 {
  background-image: url(https://picsum.photos/id/1/200/300);
  background-size: cover;
}
<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <title>City</title>
  <link href="wwd.css" rel="stylesheet" type="text/css">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <script src="index.js"></script>
</head>

<body>
  <div class="main">
    <div class="row">
      <h1>Overview</h1>
      <div class="row-text-top">
        One of the most urgent issues of our time, climate change has widespread implications — from the exacerbation of poverty, to the breakdown of infrastructure, to the loss of environmental, political, economic and social security. Experts agree that climate
        change threatens to set back development efforts by decades, placing least developed countries and already-vulnerable populations in an even more precarious position.
      </div>
      <div class="row-text-mid">
        The latest Intergovernmental Panel on Climate Change (IPCC) Fifth Assessment Report (AR5), signed off by almost 200 nations, concludes with 95% certainty or more that humans have caused the majority of climate change since the 1950s. It predicts global
        surface temperature to continue to rise, along with increased sea level rise, melting of glaciers and ice sheets, acidification of oceans, increase in the intensity of tropical storms and changes in precipitation patterns.
      </div>
      <div class="row-text-mid1">
        In other words; the science on climate change is clearer than ever, and so is the urgency for human action.
      </div>
      <div class="row-text-low">
        As a global community, we all have a role in developing and implementing solutions toward significant transformation in our development patterns. It requires not only a shift in awareness and accountability for our own individual choices but in a social,
        political and economic shift towards enabling conditions for these sustainable choices to be made– and in turn, a more just, equal and healthy planet.
      </div>
    </div>
    <div class="row1">
    </div>
  </div>
</body>

</html>