Creating equal heights for the floating blocks to ensure they remain aligned at the same level

Encountered with a challenge like this. There is a large block (referred to as container), which is split into two sections col-4 and col-8. The container consists of fixed height blocks at the top, while there are blocks that need to have floating height. Additionally, there is a block with scroll functionality.

How can I set the height with a scroll feature to be floating? I am having trouble identifying the issue in my code below.

View image description here

.all-height {
        min-height: 100%;
      }

      .all-height__itme-one {
        background: #5bc0eb;
        height: 200px;
        margin-bottom: 20px;
        padding: 10px;
      }

      .all-height__itme-two {
        background: #e7606b;
        min-height: 300px;
        margin-bottom: 20px;
        padding: 10px;
      }

      .all-height__itme-three {
        background: #68d8d6;
        height: 500px;
        margin-bottom: 20px;
        padding: 10px;
        overflow-x: scroll;
      }

      .all-height__itme-three-item {
        margin-bottom: 20px;
        background-color: #e7606b;
        padding: 15px;
        color: #fff;
      }

      .all-height__itme-four {
        background: #59a5d8;
        height: 100%;
        margin-bottom: 20px;
        padding: 10px;
      }

      .all-height__itme-five {
        background: #ccd42c;
        height: 100%;
        margin-bottom: 20px;
        padding: 10px;
      }
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>

<div class="container">
  <div class="row align-items-stretch">
    <div class="col-xl-4">
      <div class="all-height">
        <div class="all-height__itme-one">
          <p>This unit with fixed height</p>
        </div>
        <div class="all-height__itme-three">
          <p>Floating altitude</p>
          <div class="all-height__itme-three-item">Lorem ipsum dolor</div>
          <!-- More items -->
        </div>
      </div>
    </div>
    <div class="col-xl-8">
      <div class="all-height">
        <div class="all-height__itme-two">
          <p>This unit with fixed height</p>
        </div>
        <div class="row align-items-stretch">
          <!-- Two more columns -->
        </div>
      </div>
    </div>
  </div>
</div>

Answer №1

If you're looking to extend the Lorem ipsum content columns so they match the height of the left columns, one solution is to assign an extra class to the right column and adjust the items using flexbox:

.all-height {
  min-height: 100%;
}

.all-height__itme-one {
  background: #5bc0eb;
  height: 200px;
  margin-bottom: 20px;
  padding: 10px;
}

.all-height__itme-two {
  background: #e7606b;
  min-height: 300px;
  margin-bottom: 20px;
  padding: 10px;
}

.all-height__itme-three {
  background: #68d8d6;
  height: 500px;
  margin-bottom: 20px;
  padding: 10px;
  overflow-x: scroll;
}

.all-height__itme-three-item {
  margin-bottom: 20px;
  background-color: #e7606b;
  padding: 15px;
  color: #fff;
}

.all-height__itme-four {
  background: #59a5d8;
  height: 100%;
  margin-bottom: 20px;
  padding: 10px;
}

.all-height__itme-five {
  background: #ccd42c;
  height: 100%;
  margin-bottom: 20px;
  padding: 10px;
}

.right-col{
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;      
}

.right-col .all-height__itme-two{
  flex-grow: 1;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>

<div class="container">
  <div class="row align-items-stretch">
    <div class="col-xl-4">
      <div class="all-height">
        <div class="all-height__itme-one">
          <p>This unit with fixed height</p>
        </div>
        <div class="all-height__itme-three">
          <p>Floating altitude</p>
          <div class="all-height__itme-three-item">Lorem ipsum dolor</div>
          <!-- More items here -->
        </div>
      </div>
    </div>
    <div class="col-xl-8">
      <div class="all-height right-col">
        <div class="all-height__itme-two">
          <p>This unit with fixed height</p>
        </div>
        <div class="row align-items-stretch">
          <div class="col-lg-6">
            <div class="all-height__itme-four">
              <p>Lorem ipsum dolor, sit amet consectetur adipisicing elit.?</p>
            </div>
          </div>
          <div class="col-lg-6">
            <div class="all-height__itme-five">
              <p>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Doloribus, voluptatum hic modi unde laudantium quia officia totam maxime doloremque labore eius exercitationem harum minima deserunt aspernatur corporis enim beatae quis?</p>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

In addition, consider removing the margin-bottom from the all-height__itme-three element since it affects the overall alignment of the items in that column.

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

What is the most appropriate unit of measurement for creating a responsive design?

I am a beginner in the world of responsive design and I'm currently figuring out how to properly layout plugins on a website when viewed on smartphones. Here's an example: @media (min-width: 568px) { .musicPlayer{ width:600px; height:320 ...

HTML declaration vandalized site

There's a strange bug I've encountered with the use of !DOCTYPE html. Whenever I attempt to implement the HTML5 Doctype, my page ends up looking distorted. It seems like all scripts are not properly closed. However, when I switch to !DOCTYPE ht ...

Customizing Material UI Popover CSS classes within a Select component in a React application

I have integrated the Material UI Select component into my React project. I am attempting to customize the CSS classes .MuiPaper-root and/or .MuiMenu-list. This is how my Select component looks: <Select value={selectValue} disableUnderline onCha ...

How to Apply "novalidate" in Bootstrap 4 for Custom Form Validation in Rails 5.1

I am testing out Bootstrap 4 forms and its native validation for the first time. After running this code, I noticed that default error messages show up because I did not set the novalidate value. <%= form_tag contact_path, class: "needs-validation", m ...

What is the best way to align an element in the middle of a div when there is another element in

I am trying to center an element within a div while another element is positioned nearby. Using text-align: center gets the element close to where I want it, but not exactly due to the presence of another element. My goal is to have the logo element center ...

Tips for vertically centering text within a textarea nested in a flexbox within a grid framework

Struggling to center text inside a textarea within a flexbox nested in a grid? Despite my efforts, I can't seem to crack it. Here's the Fiddle code snippet: // Attempting to Center Text const myDocumentAreaFiltersGlobalDisplay = document.getEl ...

Validation failure in the CSS document - Syntax error

I have searched high and low for a solution to my CSS 3.0 validation issue, but none seem to fit the bill. I am struggling with parse errors in the beginning and despite checking for invisible characters, I can't seem to pinpoint the problem. What co ...

What is the best way to convert this html code into php?

I’m trying to figure out how to incorporate all of this into my loop, but I’m not sure if it can be broken up. However, PHP needs to interpret it as HTML. $movieDetails = <header class="masthead" role="banner"> <div class="logo-con ...

Problems with Text Gradients in Edge and Safari

My attempt at creating a text gradient in WordPress (utilizing SiteOrigin pagebuilder) is not successful in Edge or Safari; the text appears colorless in both browsers. I have experimented with the following recommendations: CSS3 Text Gradients not workin ...

Difficulty Navigating Table Elements Using jQuery

My goal is to hide specific elements within a table by using a jQuery function that iterates through each row, checks the row's class, and hides it based on the result. However, I've encountered an issue where the function only checks the first r ...

Position the navbar as an overlay when expanding, instead of pushing down the page contents

Is there a way in bootstrap 4.0 to have the navbar overlaying the contents of a page when it expands from the collapsed state, instead of pushing the contents down? I've experimented with setting z-index properties on the navbar and other classes, as ...

Enhancing this testimonial slider with captivating animations

I have designed a testimonial slider with CSS3 and now I am looking to enhance it by adding some animation using Jquery. However, I am not sure how to integrate Jquery with this slider or which plugins would work best for this purpose. Can anyone provide g ...

The program encountered an error while trying to access the undefined property '_header'

An issue arises when the app.use(express.static("web")) line is executed. var express = require('express')(); var app = express(); var http = require('http').Server(app); var io = require('socket.io')(http); //app.get(&apo ...

The 'getGridMerchantLocationData' function contains duplicate definitions for both DataSource and DataSourceID. Please remove one of the definitions

I am having trouble binding data from a dataset. Can someone review my code and point out where I may be going wrong? The current issue is that it's not binding and throwing an exception: "Both DataSource and DataSourceID are defined on 'getGridm ...

Animate elements using fixed position without unexpected jumps

Trying to create an animation that expands a box to full screen. However, when I set the position to fixed before the animation begins, the box quickly moves up to the upper left corner. Is there a way to make it expand from its original location instead? ...

Is CSS causing a overflow when trying to print 210mm by 297mm on A4?

Take a look at this basic HTML code : <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <style type="text/css"> .page { width: 200px; height: 500px; background ...

Link social media buttons to specific posts

I've developed my own PHP blog from scratch. The homepage showcases all the latest posts. I integrated Facebook Like and Tweet buttons beneath the title of each post, but they are currently functioning for the entire homepage instead of each specific ...

What is the best way to distinguish between relative blocks and convert them to absolute positioning?

What is the best way to locate relative blocks and convert them to absolute position while keeping them in the same place? Is this something that can be achieved using JavaScript or jQuery, or is it simply not possible? Thank you very much. ...

A comparison of day and time in PHP

Greetings! I am a beginner in PHP and Stackoverflow, seeking assistance on determining whether today's date and time falls within specified days and times. Once established, I aim to display either "Shop closed" or "Shop opened" based on the condition ...

Adding elements to an existing CSS class can be accomplished by using the class attribute

Can I modify my existing CSS class by adding new elements? CSS: .usrgrid { color:blue; background-color:white; } Is there a way to add attributes to the .usergrid class? I attempted using $(.usergrid).css("display","block"); but it didn't ...