0

I have a problem that although I used padding-bottom:0; in style for the class .title but there are still white spaces between .title and #about_restaurant. May I ask if I want to cut the excess white spaces between two elements what is the best way to solve it?

#about_restaurant {
  background-color: yellow;
  width: 100%;
  height: 240px;
  padding-top: 0;
  display: flex;
  align-items: center;
}

.delivery_image {
  flex: 0 0 auto;
  padding: 1em;
}

.delivery_image img {
  display: block;
  border-radius: 50%;
}

.describe_restaurant {
  float: left;
}

.describe_restaurant h2 {
  flex: 1 1 auto;
  padding: 1em;
}

.title {
  text-align: center;
  background-color: aqua;
  padding-bottom: 0;
}
<div class="container-fluid">
  <div id="About">
    <h2 class="title">About Restaurant</h2>
    <div id="about_restaurant">
      <div class="delivery_image">
        <img src="delivery.jpg" width="250" height="250">
      </div>
      <div class="describe_restaurant">
        <h2>Our restaurant aimed to provide delivery service to the customers. We hope the service and the quality of food could satisfy the customers' expectations. Welcome to support our delivery service.
        </h2>
      </div>


    </div>
  </div>
</div>
Temani Afif
  • 245,468
  • 26
  • 309
  • 415

2 Answers2

0
    .title{
       text-align:center;
       background-color:aqua;
       padding-bottom:0;
       margin-bottom:0;
    }

or :

<h2 class="title" style="margin-bottom:0;">About Restaurant</h2>
Met Br
  • 634
  • 5
  • 9
0

That white space is the default margin of the header (<h2></h2>). you can reset it by using: h2 { margin: 0; } in your css file.

Paddings are the inside spacing of an element. However the white-space is not added in the inside of an element but outside. The outside spacing is called margin. As such, padding: 0; wont help you here.

h2 {
  margin: 0;
}

#about_restaurant {
  background-color: yellow;
  width: 100%;
  height: 240px;
  padding-top: 0;
  display: flex;
  align-items: center;
}

.delivery_image {
  flex: 0 0 auto;
  padding: 1em;
}

.delivery_image img {
  display: block;
  border-radius: 50%;
}

.describe_restaurant {
  float: left;
}

.describe_restaurant h2 {
  flex: 1 1 auto;
  padding: 1em;
}

.title {
  text-align: center;
  background-color: aqua;
  padding-bottom: 0;
}
<div class="container-fluid">
  <div id="About">
    <h2 class="title">About Restaurant</h2>
    <div id="about_restaurant">
      <div class="delivery_image">
        <img src="delivery.jpg" width="250" height="250">
      </div>
      <div class="describe_restaurant">
        <h2>Our restaurant aimed to provide delivery service to the customers. We hope the service and the quality of food could satisfy the customers' expectations. Welcome to support our delivery service.
        </h2>
      </div>


    </div>
  </div>
</div>
tacoshy
  • 10,642
  • 5
  • 17
  • 34