Ensure all boxes have equal heights

I'm using Boostrap 5 and I have four boxes that are not cards. How can I ensure they are the same height, considering the dynamic content?

You can access the Codepen for more information: https://codepen.io/Deluxe23/pen/gOXJWwG

Below is an excerpt of the HTML code featuring just two boxes, as posting the entire code here would be excessive. You'll see all four boxes in the Codepen sample.

.box>.icon {
  // CSS styles here
}
// More CSS styles for the boxes...
.box .space {
  height: 30px;
}
// HTML markup for the first box
<div class="col-6 col-sm-6 col-lg-3">
  <div class="box ">
    <!-- Box content here -->
  </div>
</div>

// HTML markup for the second box
<div class="col-6 col-sm-6 col-lg-3">
  <div class="box ">
    <!-- Second box content here -->
  </div>
</div>

Answer №1

After making some adjustments to your code structure and tweaking the necessary CSS properties, I managed to ensure that the design remains intact while fixing the height issues. If there are any specific styling elements that were omitted, such as font decorations, you will need to reapply them. The main modification I made was moving the background and border color declarations from `info` to `box`, as `box` serves as the parent container for all child elements (including `info`), making it more logical for these styles to be applied there.

Furthermore, to prevent layout issues when resizing the columns horizontally without a defined minimum width breakpoint causing them to wrap onto a new line, I set the min-height of all `box` elements to match the largest rendered height. In this case, it corresponds to box #3 with the lengthy `p` text content.

You can see the adjusted layout at lower browser widths by viewing the full height text example here. Since all boxes now share the same min-height value, they will always align properly.

For a live demonstration, refer to the updated code snippet below:

{CSS CODE HERE}
{HTML CODE HERE}

Answer №2

Insert New Class

<div class="col-6 col-sm-6 col-lg-3 newClass">
        <div class="box h-100 newClass"> /* Add New Class Here*/
          <div class="icon h-100 d-flex flex-column newClass">  /* Include New Class Here*/
            <div class="image" style="padding-top:14px;line-height:0px;padding-left:2px"><img src="data:/EcctII.webp" decoding="async" class="lazyload"><noscript><img src="https://iili.io/EcctII.webp" style="max-width:45px;max-height:45px" data-eio="l"></noscript></div>
            <div class="info flex-fill newClass">  /* Put New Class here*/
              <h3 class="title">BoxHeadline 4</h3>

Answer №3

Please ensure you update with the following code snippet for full height: height : 100%

.box > .icon { text-align: center; position: relative; }
.box > .icon > .image { position: relative; z-index: 2; margin: auto; width: 88px; height: 88px; border: 8px solid white; line-height: 88px; border-radius: 50%; background: blue; vertical-align: middle; }
.box > .icon:hover > .image { background: #333; }
.box > .icon > .image > i { font-size: 36px !important; color: #fff !important; }
.box > .icon:hover > .image > i { color: white !important; }
.box > .icon > .info { margin-top: -24px; padding: 40px 0 10px 0; }
.box > .icon:hover > .info { border-color: #e0e0e0; color: white; }
.box > .icon > .info > h3.title { font-family: "Montserrat",sans-serif !important; font-size: 1.25rem; color: #222; font-weight: 500; }

... (additional CSS code here)

<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="73111c1c07000701120333465d425d40">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c2a0adadb6b1b6b0a3b282f7ecf3ecf1">[email protected]</a>/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>

<section style="background-color:#f7f7f7">
  ... (HTML content goes here)
</section>

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

Placing a Label Next to an Input Field using Bootstrap 4

Is there a way to position the label right next to the input form? I've attempted different methods without success. Could you please review my code below? <div class="modal-body"> <form class="form-horizontal"> <div cl ...

BOOTSTRAP Issue: The sticky footer in the template is not staying sticky

I am at the point where I am tempted to open my window and throw my computer out. I followed a tutorial on Bootstrap for the footer template. Everything looks good, but when my text extends beyond one page, the footer remains stuck in place and does not m ...

The particles-js effect only partially fills the page

I've encountered some issues with particles-js. Firstly, it fails to cover the entire page. Additionally, I seem to be unable to interact with the particles for reasons unknown. Here is the HTML code snippet: <script type="text/javascript" src="j ...

Field input displacement

I am experiencing an issue with my contact form, specifically with the message subject field displayed as a menu. The problem only seems to occur on wide desktop displays, where it appears offset from the rest of the form. Despite my efforts to troublesho ...

Stop the form submission until validation is complete

I'm currently working on a form and encountering some validation issues. HTML: <form id="regForm" class="form-group" method="POST" action="signup.php"> <div class="col-md-12"> <h2>Job Pocket</h2> </div> <di ...

Images are not appearing correctly on Chrome browsers when using Windows operating system

img tags seem to have unusual margins in Chrome, Edge, and Opera browsers, while Firefox displays them correctly. Queries What is causing these margins specifically in Chrome? The Devtool does not detect any margin properties. Is there a straightforward s ...

The website's text content loads first, allowing for images to take their time and load afterwards

My priority is to ensure that my images load as quickly as HTML and CSS. Currently, the loading time for images (all in .svg format and small) exceeds 2 seconds after other content loads, despite HTML and CSS loading swiftly. Is there a method to expedite ...

Create a stunning design with Bootstrap 4 by incorporating a full-width background for both the table header and rows,

Bootstrap 4 offers a convenient table feature, but I'm having trouble aligning it with the design provided to me. The design requires full-width background colors for both the dark header (thead) and the light body (tbody), all while keeping the eleme ...

Declaration of Character Encoding in CSS3

Do I need to include a character encoding declaration in CSS3? When I add the @charset "utf-8"; declaration, Visual Studio's CSS3 validation displays a warning. Can anyone offer some guidance on this issue? ...

What steps can I take to bring my text more in line with my header?

How can I adjust the spacing between my small text and big text on my website? Here is a snippet of my HTML code: <div class="header"> <br> <br> <br> <br> <h1>Summi ...

wildfly: how do I ensure static content is displayed before deployment?

I am currently running a geoserver application on a wildfly server, and I need to redirect a specific endpoint to another one in order to protect sensitive information. Whenever a user accesses https://localhost/geoserver, I want them to be redirected to h ...

Ways to verify the presence of an element in a list

I found this interesting JS code snippet: ;(function ($) { $('.filter-opts .opt').click(function(){ var selectedName = $(this).html(); $('.append').append('<li>' + selectedName + '</li> ...

Navigating URLs in various Android browsers: Tips and Tricks

I am on a quest to find a method to engage with various android browsers. My goal is to retrieve the URL of the website being viewed by the browser. I want my app to operate in the background and issue an alert when a designated URL is accessed, primarily ...

Prime NG: Filtering options using label in dropdown menu

I'm facing an issue with my angular project that utilizes prime ng. The problem arises when attempting to perform a column search on rows of dropdown values. When searching for 'Jan', the system fails to retrieve any data, but interestingly ...

Switch videos within the video tag as you scroll

I am trying to implement a video tag within a div element on my website. Here is the current code: <div class="phone" align="center"> <div class="phone-inner"> <video width="100%" height="100%" autoplay="" loop="" muted id="phonevideo ...

The solution for fixing contenteditable is as follows:

I am currently working on a script to clean up pasted text within a contenteditable div. While the script is functioning well for most part, I have noticed that in Firefox, line breaks get removed when the text is copied within or between the divs. Does ...

Guide on extracting the data related to the clicked link in Django

I have a database that includes information about books, such as Id, title, rating, page count, and author. On my home.html page, I want to display the book titles as clickable links. When a user clicks on a title, it should redirect them to another page ...

The redirection of the URL after form submission is not functioning correctly

I'm attempting to develop a pair of dropdown lists in Elementor where the second dropdown's options depend on what is selected in the first, and the second contains URLs linked to a GO button that redirects to the chosen URL. However, I've f ...

The array is producing accurate results, however it is displaying as undefined in the HTML output

I have encountered a problem while working on my project. I am utilizing an API to fetch an array of platforms where a video game is available. Although the array is returning the correct data, I am facing difficulty in displaying these values in my HTML a ...

Angular's table data display feature is unfortunately lacking

Below is a simple HTML code snippet: <div class="dialogs"> <div id="wrapper" > <p>{{createTestingConstant()}}</p> <ng-container *ngFor="let one of contacts"> <p>{{one ...