Adjusting Window Size Causes White Space to Appear Above Div

I currently have two inline-block div in my post page that showcase my latest book reviews. Typically, these sections align perfectly and occupy the same amount of space on the screen. However, for certain window sizes, one of the inline-block elements ends up taking less space than the other, resulting in white space at the bottom of the smaller div.

Is there a way to eliminate this unnecessary whitespace?

Below is the HTML and CSS I am using:

html, body {
margin: 0;
padding: 0;
}
.newest-review-cover {
  z-index: 0;

}

.newest-review-cover img {
  display: block;
  height: 50%;
  width: 100%;


}

.newest-review-content h2 {

color: white;
font-size: 2rem;
padding-top: 1em;
}

.newest-review-content h5 {
padding: 1em 3em;
color: white;
font-size: 1rem;

}

.newest-review-content {
background-color: black;
padding: 2em 0;
text-align: center;

}

.book-review img{
  width: 100%;
  height: 200%;

  



}

.book-review {
background-color: black;
display: inline-block;
width: 33%;
padding-left: 0;
border-right: solid 3px #f28600;
border-left: solid 3px #f28600;
border-top: solid 5px #f28600;
margin-left: -4px;
margin-top: 0;
vertical-align: top;

}

.book-review p {
color: white;
margin: 1em 0;
}

.post-title {
text-align: center;
}

.post-description {
padding: 0 2em;
height: 100px;
}
<!DOCTYPE html>
<html>

<head> 
<link href="header+footer.css" rel = "stylesheet" type="text/css" />
<link href="Homepage.css" rel = "stylesheet" type="text/css" />
 <meta charset="utf-8">
<title> The Novel Column - Book Reviews </title>

</head>


<body>

<nav>

<h1> <a href="index.html"> The Novel Column </a> </h1>

<ul>
<li> <a href="#"> Resources </a>
<ul> 
<li> <a href="#"> Book Reviews </a> </li>
<li> <a href="#"> Quotes and Principles </a> </li>
<li> <a href="#"> Community Aid </a> </li>

</ul>
</li>
<li> <a href="#"> About Us </a> </li>
</ul>

</nav>

<section class="newest-review-cover"> 
<img src="images/the-5am-club-poster.jpg" alt="The 5AM Club">

<div class="newest-review-content"> 
<h2> The 5AM Club Review </h2>
<h5> Maximize your productivity, be around nice things, and spend more time doing what you want! </h5>
</div>
</section>

<div class="all-posts"> 
<a href="the-one-thing.html">
<div class="book-review" id="the-one-thing"> 
<img src="https://thenovelcolumn.com/wp-content/uploads/2019/05/The-ONE-Thing-Image-3.jpg" alt="The ONE Thing">

<div class="book-description">
<p class="post-title"> The ONE Thing Review </p>
<p class="post-description"> Declutter your life, think big, and achieve mastery!</p>
</div>

</div>
</a>

<a href="the-10x-rule.html">
<div class="book-review" id="the-10x-rule">
<img src="https://thenovelcolumn.com/wp-content/uploads/2019/04/The-10X-Rule-Image-2-e1555476700855.jpg" alt="The 10X Rule" alt="The 10X Rule">

<div class="book-description">
<p class="post-title"> The 10X Rule Review </p>
<p class="post-description"> Unlock your potential and multiply happiness and productivity!</p>
</div>
</div>
</a>

</div>



</body>


</html>

Thank you for your assistance!

Answer №1

I believe the issue stems from the .post-description element

If you compare the text height of the .post-description in both blocks, they appear to be different.

You could specify a fixed height for .post-description and apply vertical-align: top; to .book-review

html, body {
margin: 0;
padding: 0;
}
.newest-review-cover {
  z-index: 0;

}

.newest-review-cover img {
  display: block;
  height: 50%;
  width: 100%;


}

.newest-review-content h2 {

color: white;
font-size: 2rem;
padding-top: 1em;
}

.newest-review-content h5 {
padding: 1em 3em;
color: white;
font-size: 1rem;

}

.newest-review-content {
background-color: black;
padding: 2em 0;
text-align: center;

}







.book-review img{
  width: 100%;
  height: 200%;

  


}



.book-review {
background-color: black;
display: inline-block;
width: 33%;
padding-left: 0;
border-right: solid 3px #f28600;
border-left: solid 3px #f28600;
border-top: solid 5px #f28600;
margin-left: -4px;
margin-top: 0;

  vertical-align: top; /*Added this to set alignment to top*/


}

.book-review p {
color: white;
margin: 1em 0;
}

.post-title {
text-align: center;

}



.post-description {
padding: 0 2em;
    height: 150px; /*Added a fixed height*/
}
<!DOCTYPE html>
<html>

<head> 
<link href="header+footer.css" rel = "stylesheet" type="text/css" />
<link href="Homepage.css" rel = "stylesheet" type="text/css" />
 <meta charset="utf-8">
<title> The Novel Column - Book Reviews </title>

</head>


<body>

<nav>

<h1> <a href="index.html"> The Novel Column </a> </h1>

<ul>
<li> <a href="#"> Resources </a>
<ul> 
<li> <a href="#"> Book Reviews </a> </li>
<li> <a href="#"> Quotes and Principles </a> </li>
<li> <a href="#"> Community Aid </a> </li>

</ul>
</li>
<li> <a href="#"> About Us </a> </li>
</ul>

</nav>

<section class="newest-review-cover"> 
<img src="images/the-5am-club-poster.jpg" alt="The 5AM Club">

<div class="newest-review-content"> 
<h2> The 5AM Club Review </h2>
<h5> Maximize your productivity, be around nice things, and spend more time doing what you want! </h5>
</div>
</section>

<div class="all-posts"> 
<div class="book-review" id="the-one-thing"> 
<img src="https://thenovelcolumn.com/wp-content/uploads/2019/05/The-ONE-Thing-Image-3.jpg" alt="The ONE Thing">

<div class="book-description">
<p class="post-title"> The ONE Thing Review </p>
<p class="post-description"> Declutter your life, think big, and achieve mastery!</p>
</div>

</div>
 
<a href="the-10x-rule.html">
<div class="book-review" id="the-10x-rule">
<img src="https://thenovelcolumn.com/wp-content/uploads/2019/04/The-10X-Rule-Image-2-e1555476700855.jpg" alt="The 10X Rule">

<div class="book-description">
<p class="post-title"> The 10X Rule Review </p>
<p class="post-description"> Unlock your potential and multiply happiness and productivity!</p>
</div>
</div>
</a>

</div>



</body>


</html>

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

Tips for creating a clickable title that directs to a URL

I am currently using the "Import All" WordPress plugin to bring in an Excel file containing numerous hyperlinks that point to specific Custom Post Types and a designated field. These hyperlinks are separated by commas from the corresponding title. For exam ...

Adaptive web layout (Adjusting design based on screen size)

I'm feeling a bit confused about responsive web design. I understand that I can use media queries to apply different stylesheets based on specific screen sizes. For example, a screen at 600px will use one stylesheet while a larger screen will use a co ...

Styling a Razor view using inline CSS and responsive media queries

I need to add some simple inline styling for print purposes to an .cshtml page I'm working on. I initially tried using the @media print media query, but it is causing issues with my cshtml page. Is there a workaround for this problem? The culprit see ...

arrangement of a list with the specified information stored in each item

Presently, my task involves setting up a dynamic gallery page with multiple tabbed lists that are fetched from the database. Each list corresponds to a specific Gallery Name and is associated with a unique data-list-id. Furthermore, each gallery contains ...

Incompatibility Issue with Ajax Request on iPad 1 (iOS 5.1.1)

Having an issue with reloading content on my iPad web app. The get request works fine in the browser, but I'm experiencing trouble in Safari on the iPad 1 (iOS 5.1.1). Any suggestions on how to fix this? <script type="text/javascript"> ...

Center the navbar menus at the bottom

Trying to position two menus on a webpage can be challenging. One needs to show at the center bottom, while the other should appear in the top right corner. When attempting to achieve this layout, it's important to ensure that both menus are displayed ...

Is there a way to adjust the spacing between a specific background image in a design pattern? The image must be sourced online

I am currently working on creating a background pattern using only online images, and I need to adjust the spacing between them. Is there a way to specifically control the space between the images in the pattern using CSS? I know about the round and space ...

Ways to align content on navbar (Bootstrap 5)

I am currently working on a minimal navbar design using Bootstrap 5. In this setup, there are two main elements - the 'navbar-brand' for the logo/brand and the navigation links. My goal is to have the brand/logo aligned all the way to the left, ...

Implement a unique InfoWindow for every individual polygon within the Google Maps API

Currently facing difficulties in implementing an infowindow for each polygon that has been created. Attempted various code samples from different sources without success. Below is the existing code snippet, but clicking on a polygon does not trigger any ac ...

What is the best way to locate a div element with a specific style?

What is the method to locate a div element by its style? Upon inspecting the source code in IE6, here is what I find: ...an><div id="lga" style="height:231px;margin-top:-22px"><img alt="Google"... How can this be achieved using JavaScript? ...

What could be causing the lack of functionality in my nested CSS transition?

My markup includes two classes, fade-item and fade. The fade class is nested within the fade-item class as shown below: <a class="product-item fade-item" (mousemove)="hoverOn(i)" (mouseleave)="hoverOff(i) > <div class= ...

PHP - attempted to restrict file size, only to receive a warning: The POST Content-Length surpasses the designated limit

Recently, I decided to experiment with the file upload functionality on my website. The upload file code allows users to either select a file for upload or submit it without any attachment. Initially, I implemented an error message that restricts the file ...

Steps to keep the gridlines in the chart from moving

Take a look at the example provided in the following link: Labeling the axis with alphanumeric characters. In this particular instance, the gridlines adjust dynamically based on the coordinate values. How can we modify this so that the chart remains static ...

Tips for showing a variety of headers on your page

I am struggling to align multiple headers on the same horizontal line. Despite my efforts, only two of them display correctly while the third keeps dropping down a line. To see what I mean, take a look at this image: view current layout Here is the code ...

Creating an expand and collapse animation in a `flex` accordion can be achieved even when the container size is fixed using

Good day, I am in need of a fixed-height HTML/CSS/JS accordion. The requirement is for the accordion container's height to be fixed (100% body height) and for any panel content overflow, the scrollbar should appear inside the panel's content div ...

Implement a smooth transition effect when changing the image source

I am currently working on enhancing a Squarespace website by adding a new image fade-in/fade-out effect when the mouse hovers over one of three buttons. The challenge I'm facing is that the main static image is embedded as an img element in the HTML r ...

Navigate to a PDF file from an HTML5 application using PhoneGap by accessing an external link

Can anyone help me figure out what I'm doing wrong here? Essentially, I am trying to open a PDF in Google Viewer: <a id="pdflink" href="https://docs.google.com/viewer?url=http://pdpdpd.pdf" target="_blank">Pdf</a> When it opens in the vi ...

Discover the sleek and modern concept of transparency in Microsoft's

I'm interested in incorporating Microsoft Fluent Design transparency into my webpage. Are there any CSS or other tools that can help achieve this design language? I want to enhance the look of my site with these elements. ...

CSS for when the mouse hovers over an element

Two php files and a js file are involved in this scenario. The issue at hand is that when the div is clicked, it navigates to a new page with an appended # to the URL, causing it to scroll to the specified comment ID. However, instead of scrolling to the c ...

Guide to positioning a border with CSS

How can I align a border to the right in this code? This is the CSS snippet that I currently have: p { text-align: right; color: #757575; Background-color: #FFFFFF; font-size: 2.4em; width: 50px; } <p>Home<br> <a href="aboutu ...