I struggle with removing unnecessary white spaces between two divs

There seems to be an issue with the spacing between the elements .title and #about_restaurant, even after applying padding-bottom:0; to the .title class. How can I reduce the excess white spaces between these two elements?

#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>

Answer №1

When dealing with white space as the default margin of the header (<h2></h2>), you have the option to reset it by adding h2 { margin: 0; } in your css file.

Paddings refer to the inside spacing of an element. On the other hand, white-space is not considered inside spacing but rather outside. This external spacing is known as margin. Hence, setting padding: 0; will not address this issue.

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>

Answer №2

    .header{
       text-align:center;
       background-color:skyblue;
       padding-bottom:10px;
       margin-bottom:5px;
    }

Alternatively:

<h2 class="header" style="margin-bottom:15px;">Restaurant Information</h2>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Unable to view new content as window does not scroll when content fills it up

As I work on developing a roulette system program (more to deter me from betting than to actually bet!), I've encountered an issue with the main window '#results' not scrolling when filled with results. The scroll should always follow the la ...

How can I access an InputStream from a local XML file in a PhoneGap application?

Looking for advice on how to fetch an inputstream from a local XML file using JavaScript in my PhoneGap application. I'm new to JavaScript, so any guidance would be appreciated! ...

What causes the layout of an application to become distorted when I extend the theme in Tailwind.css?

I had the idea of incorporating an animation into my website design using tailwind.css for styling. module.exports = { content: ["./index.html", "./src/**/*.{js,jsx}"], theme: { colors: { primary: "#E51114", ...

What steps can I take to ensure that my header remains static while my slides move in fullpagejs?

I need help with fixing the header in my fullpagejs slide. The header currently moves along with the slide, but I want it to stay in place within the background image. When I try taking the header out of the background section, it creates a white space at ...

Modify the appearance of every instance of a specific phrase

Looking to give my site title a unique font separate from the rest of the content every time it appears in a heading. This is all for branding purposes. Let's say my custom font is Courier and my company goes by the name SparklePony. For example, if t ...

Tips for displaying a loading message during an AJAX request?

My AJAX function is set up like this: function update_session(val) { var session_id_to_change=document.getElementById('select_path').value; $.ajax({ type: "GET", url: "/modify_path/", asy ...

The pull-right function doesn't seem to function properly when applied to a button within a Bootstrap alert

Within my Bootstrap alert, I have a text and an undo button displayed. However, the button is not aligned correctly to the right, causing a misalignment with the close button on the right and the text on the left. I attempted to resolve this issue using th ...

An error occurred in jQuery.ajax: The object's property 'xhr' is not a function

I'm facing an issue with a jQuery.ajax object where I am trying to replace xhr. When I run the code below, it throws an error: TypeError: Property 'xhr' of object #<Object> is not a function The part of the code causing the error is ...

CSS tooltip within the document styling

Previously, I utilized the following code: I am seeking guidance on how to position the tooltip inline (to the right) with the parent div instead of above. Thank you for reviewing For a more user-friendly version, refer to this jsFiddle link HTML: < ...

Tips for including text and a button within the footer of a Bootstrap modal

I'm facing an issue with my Bootstrap modal footer where the output shows two divs side by side, which is not the desired result. Below is the code snippet in question: <div class="modal fade" id="itiModal" role="dialog&quo ...

Display a full-width card beneath each small card in every row using CSS

In a scenario where I have designed a layout consisting of 3 column/row cards across multiple rows. Each card displays basic information, and when a user clicks on any specific card, a full-width card below that row will display more detailed information. ...

The formatting of the list is not being correctly displayed in the Ajax Jquery list

Trying to dynamically generate an unordered list from XML onto a jQuery mobile page has been a bit of a challenge for me. While I can display the items on the page, the styling never seems to work properly, only showing up as plain text with blue links. Is ...

Using pagination with tables in HTML: A beginner's guide

I attempted to implement a paging system within a table following the instructions in this article, but unfortunately, it doesn't seem to be functioning correctly. Expected Output: https://i.sstatic.net/4ODNf.png Current Output: https://i.sstatic. ...

Angular JS webpage featuring a plethora of search filters for enhanced user experience

I just started learning Angular JS and I'm building a HTML page with over 12 different search options for users. Do I need to create separate functions for each of the 12 search options to call the REST API, or is there a more efficient way to handle ...

"Create a notification pop-up in CSS that appears when a link is clicked, similar to

I am looking to create a model page that functions similarly to the inbox popup on Stack Overflow. When we click on the inbox icon, a small box appears with a tiny loader indicating messages or comments. The box then expands depending on the content inside ...

Allowing SVGs to be clickable without disrupting the functionality of YouTube videos

I'm experiencing an issue with the overlapping of the svg and YouTube elements. If you hover your mouse over, just to the right of the svg and click, instead of opening the video, it redirects you back to the previous page. Clicking on the area betw ...

Automatically load content using AJAX when scrolling within a HTML5 segment

Recently, I've been developing a website that dynamically loads new content from a MySQL database as the user scrolls. However, I've encountered an issue where the new content is loaded even with minimal scrolling, rather than only when reaching ...

Ways to incorporate zoom and flip effects into an image with the use of CSS and jQuery

I'm attempting to incorporate both flip and zoom effects into my project, but I've only been successful in achieving one effect. The scenario is when the user clicks on the image, it zooms in. Now, I want to add a flip effect before the mouse le ...

Can CSS `content` support the combination of different font styles?

I have set up a CSS element to insert some content. Here's the code: .foo:after { content: "Bold, italics"; } What I want is for the word "Bold" to appear in bold font-weight and the word "italics" to appear in an italic font-style. I know that ad ...

Integrating HTML elements from the server-side back into the client-side

I'm attempting to send a post request to the backend and retrieve the elements from my AJAX post. The backend is Java, which sends an HTML string back to the client-side. After the user clicks on 'post', I want this string to be displayed as ...