What could be causing the additional space in this div? Any suggestions on how to resolve it?

In a mock project, there seems to be extra space at the bottom of this element.

https://i.sstatic.net/3s52c.jpg

I've reviewed the code thoroughly but I'm unable to pinpoint where the mistake lies. Can someone assist in identifying the error?

How can I eliminate the gap?

/*  DESSERT OF THE DAY  */

.container {
  display: flex;
  margin-top: 4em;
}

.image-2 {
  background-image: url(_images/cupcake.jpeg);
  height: 100vh;
  background-position: center center;
  width: 50vw;
}

.section-2 {
  width: 50vw;
}

.section-2 h3 {
  margin: 5% 35%;
  font-family: 'Josefin Sans', sans-serif;
  margin-bottom: 0%;
}

.section-2 h1 {
  margin-left: 5%;
  font-family: 'Abril Fatface', cursive;
  font-size: 4em;
}

.section-2 p {
  margin-left: 5%;
  margin-top: 20%;
  margin-right: 30%;
  font-family: 'Josefin Sans', sans-serif;
  line-height: 1.7em;
  margin-bottom: 0%;
}

.cherry {
  height: 3%;
  margin-left: 5%;
  margin-top: 2vh;
}

<!---DESERT OF THE DAY-->
<div class="container">
  <div class="image-2"></div>
  <div class="section-2">
    <h3>Dessert of the Day:</h3>
    <h1>Cherry butterscotch<br>cupcake</h1>
    <p>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Sint quibusdam corporis ex aut, quae nulla possimus voluptas rerum at a quaerat corrupti ratione et eveniet repellendus illum nobis omnis fugit. Lorem ipsum dolor sit amet, consectetur adipisicing
      elit. Laboriosam repellat velit quas doloremque magnam consectetur molestias eaque expedita? Laudantium quidem, officia consectetur officiis non at quam itaque sequi nostrum alias. Lorem ipsum dolor sit amet consectetur adipisicing elit. Ducimus
      natus voluptas perferendis! Facere nihil suscipit commodi omnis tempore, provident aliquid nostrum officia excepturi maxime minus veritatis quae mollitia facilis aut.</p>
    <img src="_images/cherry.jpeg" class="cherry">
  </div>
</div>
<!--CUSTOMER REVIEWS-->
<div class="container-2">
  <h1>What our customers say</h1>
</div>

Answer №1

/*  SPECIAL DESSERT MENU */ 

.container {
  display: flex;
  margin-top: 4em;
  margin-bottom: -400px;
}
.image-2 {
  background-image: url(_images/cupcake.jpeg);
  height: 100vh;
  background-position: center center;
  width: 50vw;
}

.section-2 {
  width: 50vw;
}

.section-2 h3 {
  margin: 5% 35%;
  font-family: 'Josefin Sans', sans-serif;
  margin-bottom: 0%;
}

.section-2 h1 {
  margin-left: 5%;
  font-family: 'Abril Fatface', cursive;
  font-size: 4em;
}

.section-2 p {
  margin-left: 5%;
  margin-top: 20%;
  margin-right: 30%;
  font-family: 'Josefin Sans', sans-serif;
  line-height: 1.7em;
  margin-bottom: 0%;
}

.cherry {
  height: 3%;
  margin-left: 5%;
  margin-top: 2vh;
}
<!--SPECIAL DESSERT MENU-->
<div class="container">
  <div class="image-2"></div>
  <div class="section-2">
    <h3>Special Dessert:</h3>
    <h1>Cherry Butterscotch<br>Cupcake</h1>
    <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Sint quibusdam corporis ex aut, quae nulla possimus voluptas rerum at a quaerat corrupti ratione et eveniet repellendus illum nobis omnis fugit. Lorem ipsum dolor sit amet, consectetur adipisicing
      elit. Laboriosam repellat velit quas doloremque magnam consectetur molestias eaque expedita? Laudantium quidem, officia consectetur officiis non at quam itaque sequi nostrum alias. Lorem ipsum dolor sit amet consectetur adipisicing elit. Ducimus
      natus voluptas perferendis! Facere nihil suscipit commodi omnis tempore, provident aliquid nostrum officia excepturi maxime minus veritatis quae mollitia facilis aut.</p>
    <img src="https://s4.uupload.ir/files/1-6-5_ssnb.jpg" class="cherry">
  </div>
</div>
<!--CUSTOMER REVIEWS-->
<div class="container-2">
  <h1>Customer Testimonials</h1>
</div>

https://i.sstatic.net/1OE18.png

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

The alignment of CSS boxes at the top is off

My challenge is to stack 3 containers horizontally, but they have different heights and the smaller ones end up at the bottom. How can I resolve this issue? This is the code snippet I am currently using for the boxes: .brand{ border: 1px solid black; bor ...

Incorporating HTML code from a Google Sheet cell and displaying it in a separate cell for visibility

In my Google Sheet, I am trying to extract HTML code from Column F in Tab2 and display it so that it appears in Column G of Tab 2 on the same row. For example, I have the following HTML code in cell F6 and I want it to be displayed in G6. Normally, the co ...

Resetting the value of a radio button input option to null using Angular2 ngModel

In my Angular2 application, I am attempting to implement radio button inputs using ngModel and value. The goal is to have three options: true, false, and null. However, I am struggling to assign a value of null to one of the inputs. Ideally, when nothing ...

Make sure your website design is responsive by setting the body to the device's

https://i.sstatic.net/3xHcx.png I'm struggling to make the body of my page responsive for mobile users. Whenever I try using this line of code, it just creates a messy layout. Any advice on how to fix this? <meta name="viewport" cont ...

What is the correct method to sanitize the data obtained from a text area before inserting it back into the same text area?

When a user enters text into a textarea, it is directly inserted into a mySQL database. To ensure its security, I apply trim, htmlentities, mysql_real_escape_string functions to sanitize the input. Additionally, magic quotes are enabled. However, when it c ...

What steps can be taken to enhance the responsiveness of this Bootstrap 4 code?

I've been trying to make this code more responsive, but I haven't found a suitable solution yet. When the browser window shrinks to mobile sizes, the list becomes too narrow and the picture/video items on the right end up small and aesthetically ...

Error message: "AngularJS encountered a $injector:modulerr error in Internet Explorer 11."

I've successfully created an AngularJS App that functions properly on most browsers like Firefox, Opera, Safari, Edge, and Chrome. However, there seems to be a compatibility issue with IE 11. When attempting to open the app in IE 11, the following er ...

I am encountering an issue with my PHP code that is causing an error

Whenever I try to submit my form, I keep encountering this error message. Can anyone offer some assistance with this issue? Error: Parse error: syntax error, unexpected '"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/u378761662/ ...

Where should you incorporate Jquery within a PHP-heavy webpage?

I'm struggling to get my script working correctly on a page I created. It's a paginate script that links to the "newsblocks" class. Where should I place the script for it to function properly? <?php /* Template Name: [Newspage] */ get_heade ...

Contrasts in characteristics of CSS images versus SVG graphics

I'm curious if there are distinctions between CSS images and SVGs on your website. When referencing CSS images, I mean images constructed with div elements in HTML and then styled using CSS (such as this: https://codepen.io/andrewrock/pen/jOEZxrY). ...

Restrict the number of simultaneous image downloads in HTML

I am currently seeking the most effective solution for throttling image downloads in a Single Page Application. Issue: When on a slow network and navigating to a details page, there is an overload of image downloads occurring which pushes browser connect ...

`Why won't my xpath expression function properly?`

<DOC NUMBER=1> <DOCFULL> --> <br><div class="c0"> <p class="c1"><span class="c2">Document 1 of 3</span></p> </div> <br><div class="c0"> <br><p class="c1"><span class="c2"&g ...

The issue with Bootstrap Vue scrollspy arises when trying to apply it to dynamic data. Upon closer inspection, it becomes evident that the elements are activating and highlighting one by

In my application built with Vue, content is displayed based on the component type (Header, Text, Image) in a JSON file. I am looking to implement scroll spy functionality specifically for the Header component containing headings. I have attempted to use ...

Uploading a file to a server using HTML and PHP: a step-by-step guide

Looking to utilize PHP as a proxy for uploading files to a server. Any advice on how I can send the uploaded files along with a Basic Authorization header? ...

What's the reason behind CSS transitions starting with a black background?

When I apply a transition to the heart, it inexplicably turns black at the start of the animation before displaying the intended gradient effect. Below is the code snippet: .heart { font-size: 2.5rem; padding-right: 2rem; } .heart:hover ...

Is there a method to iterate through an HTML quiz in order to extract text from "label for" with the value of "true"?

I need assistance with extracting all the correct answers from a multiple choice radio button quiz. The correct answers are identified by the attribute value="true" in the HTML code. Is there a way to iterate through and retrieve the text of all the corr ...

The font fails to load

I've hit a roadblock with this issue. I'm attempting to add a custom font to my project. The CSS file can be found in the directory project/css/. The font is located at project/fonts/iconfont/. In that folder, I have the following font files (alt ...

Newcomers to Visual Studio Code facing a problem with images not displaying

As a beginner in all aspects, I am currently facing an issue with displaying an image on Visual Studio Code. The problem arose when I tried to create a separate folder for the image, which resulted in a cascade of subfolders that only made things worse eac ...

After applying the rotateY function, the z-index appears to be malfunctioning

My current project involves creating a page flip effect, which requires two overlapping div elements. Initially, both divs are side by side with the second div having a -webkit-translateY(180deg) property applied to it. The first div has a z-index of 2, wh ...

How can I insert an image into a circular shape using HTML and CSS?

To achieve the desired effect, the image should be placed inside a circle with a white background. The image size should be smaller than the circle and centered within it. One possible way to accomplish this is: .icon i { color: #fff; width: 40px; ...