Uniform Column Height Functionality Exclusive to Desktop Devices

I have a snippet of code in my Bootstrap 5 website that looks like this

<div class="row mt-3">
    <div class="col-md-6 mt-3 mt-md-0">
        <a href="post/good-morning-status-shayari-68346" class="h-100"><img src="https://via.placeholder.com/500x500/" class="img-fluid blog-img lzy_img" alt="Good Morning Status Shayari" width="100%" height="100%">
        </a>
    </div>
    <div class="col-md-6 mt-3 mt-md-0">
        <div class="bg-dark text-white blog_content d-flex flex-column bg-black h-100 text-center pt-3 pb-3 px-3 mx-3">
            <h5>સપનાઓ ચા જેવા કડક હોવા </h5>
            <div class="d-flex flex-grow-1 justify-content-center align-items-center mb-0">
                <div class="">
                    <p class="">સપનાઓ ચા જેવા<br> કડક હોવા જોઈએ સાહેબ,<br> જે રાતની ઊંઘ છીનવી લે !!<br> 💐🌷🌹શુભ સવાર🌹🌷💐</p>
                </div>
            </div>
            <div class="time d-flex justify-content-between align-items-center align-items-end mt-auto border-top pt-3">
                <div class="left text-start">
                    <h6 class="mb-0"><a class="link-bold" href="https://stag.example.com/gu/category/gujarati-good-morning-status-shayari">શુભ સવાર સ્ટેટસ શાયરી</a></h6>
                    <p class="mb-0"><small>6 days ago</small></p>
                </div>
                <div class="right">
                </div>
            </div>
        </div>
    </div>
</div>

The code works fine and displays like this on desktop: https://i.sstatic.net/PsWMd.png

However, on mobile devices, the columns do not have equal height and appear like this: https://i.sstatic.net/VARsg.png

I want the columns to have the same height as the image on mobile devices as well, but it's not working as expected. I am using Bootstrap 5.2.

I have provided the code on Codeply for reference.

If anyone can help me solve this issue, I would greatly appreciate it.

Answer №1

One easy way to achieve this is by utilizing the aspect ratio helper classes. Simply add .ratio.ratio-1x1 to the inner wrapper within the .col-md-6 elements.

<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="9ffdf0f0ebecebedfeefdfaab1acb1afb2fef3eff7feae">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">

<div class="row mt-3">
  <div class="col-md-6 mt-3 mt-md-0">
    <a href="post/good-morning-status-shayari-68346" class="h-100 ratio ratio-1x1"><img src="https://via.placeholder.com/500x500/" class="img-fluid blog-img lzy_img" alt="Good Morning Status Shayari" width="100%" height="100%">
    </a>
  </div>
  <div class="col-md-6 mt-3 mt-md-0">
    <div class="bg-dark text-white blog_content d-flex flex-column bg-black h-100 text-center pt-3 pb-3 px-3 mx-3 ratio ratio-1x1">
      <h5>સપનાઓ ચા જેવા કડક હોવા </h5>
      <div class="d-flex flex-grow-1 justify-content-center align-items-center mb-0">
        <div class="">
          <p class="">સપનાઓ ચા જેવા<br> કડક હોવા જોઈએ સાહેબ,<br> જે રાતની ઊંઘ છીનવી લે !!<br> 💐🌷🌹શુભ સવાર🌹🌷💐</p>
        </div>
      </div>
      <div class="time d-flex justify-content-between align-items-center align-items-end mt-auto border-top pt-3">
        <div class="left text-start">
          <h6 class="mb-0"><a class="link-bold" href="https://stag.example.com/gu/category/gujarati-good-morning-status-shayari">શુભ સવાર સ્ટેટસ શાયરી</a></h6>
          <p class="mb-0"><small>6 days ago</small></p>
        </div>
        <div class="right">
        </div>
      </div>
    </div>
  </div>
</div>

Answer №2

.col-md-6 img {height: 100%;}
.col-md-6 { text-align: center; height:500px; }

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 advantages does creating a class that can freely float in either direction offer?

Recently, I noticed a common trend on websites like : .left { float: left; } <div class="col two left" /> Is this considered best practice? It goes against the idea of creating classes solely for styling purposes. If we wanted to change the floa ...

Maintain course focus when updating

I'm currently working on a to-do list where clicking on an item adds the "checked" class. However, when I refresh the page, everything reverts back to its original state without the checked class. How can I maintain the state of the checked items? I& ...

Having trouble understanding how to create a continuous loop for a CSS animation within the KreatureMedia Layerslider

Currently, I am using KreatureMedias Layerslider and trying to make a fullwidth wave bob up and down. This is what I have at the moment... <img class="ls-layer" data-ls="durationin:1500;scalein:1.1;offsetxin:-50;loopcount:-1;loopoffsetx:0sw;loopoffset ...

Creating a Timeout Function for Mobile Browsers in JavaScript/PHP

Currently, I am developing a mobile-based web application that heavily relies on AJAX and Javascript. The process involves users logging in through a login page, sending the data via post to the main page where it undergoes a mySQL query for validation. If ...

Connect the checkbox input to the text input

I'm facing an issue where I need to tie a checkbox input to a text input in my form. Here's the scenario: I am extracting data from a database. The primary key data serves as the value for the checkboxes. When a checkbox is selected, it should ...

Injecting CSS styles into a webpage using a Chrome extension before the page has completely loaded to achieve instant customization

As a newcomer to creating Chrome (or other browser) extensions, I am working on developing one that applies custom CSS rules to specific page elements. Overall, it seems to be functioning as intended, but with some minor issues. One issue I have encounter ...

Stylized with different images scattered across the browser window

Is there a way to ensure that all my randomly positioned images stay within the bounds of their 100% wrap without being cut off? Currently, some images are getting cut off due to the overflow: hidden setting. Also, is it possible to prevent the images from ...

I am interested in developing a Menu system that features different categories and subcategories

I am in need of assistance in creating a menu that includes both categories and sub categories. An example of what I am looking to achieve can be seen on the website www.boots.com If anyone has any suggestions or advice to offer, I would greatly apprecia ...

In MUI v5 React, the scroll bar vanishes from view when the drawer is open

Currently, I am working on developing a responsive drawer in React using mui v5. In the set-up, the minimum width of the drawer is defined as 600px when it expands to full width. However, an issue arises when the screen exceeds 600px - at this point, the d ...

Alert: CSS 4.0 Warning Validation - The value "rgb(0, 0, 0, 0.4)" is not valid for the "border" property

Wrapping up my asp core 3 project, I've been addressing various warnings that have popped up. However, one particular warning has me stumped. The CSS property in question is functioning perfectly, adding a touch of transparency to the black border. Wh ...

When using font size in rem units, it will remain consistent across different screen sizes and not be subject to scaling

When setting padding, margin, and font size using rem units, I noticed that on larger screens the output looks good. However, on smaller screen devices, the sizes do not reduce proportionally - instead, the measurements from the larger screen persist. Wh ...

Employ the power of AJAX to selectively display or conceal a specific group of images

Have you ever thought about showcasing a large number of images on a non-CMS website? Say you have 50 images that can't all be displayed at once. One idea is to display the first 15, then allow users to click "Next" to reveal the next batch of 15, and ...

Ways to retrieve the HTML radio button's value

Within my HTML document, the following code snippet is present: ... <div class="tab-pane fade" id="account-notifications"> <div class="card-body pb-2"> <h6 class="mb-4">Activ ...

Looking at a web page within another web page by utilizing XMLHttpRequest

Recently, I created a web app featuring a preview window that displays the content of an HTML page. To keep up with the constant updates to the HTML page, I have set the preview window to refresh every 0.5 seconds. Although the functionality works correct ...

Having trouble with Flowbite dropdown functionality in Next.js 12.* with Tailwind CSS

Hello, I am a newcomer to Next.js and currently working on a project using Tailwind/Flowbite. I copied and pasted the Flowbite search input with dropdown code from , but unfortunately, the dropdown is not functioning as expected. I have followed the docum ...

Concerns arise regarding the implementation of an image slider using HTML and CSS

Hey guys, I've created an image slider, but I'm facing an issue where the first click doesn't trigger a smooth animation. Instead, it jumps to the target without any transition. I want a seamless change of images, but right now it's jus ...

Can JavaScript impact the appearance of the printed version of a website?

Just a quick question - I currently don't have access to a printer. My client is wondering if the hidden elements of the webpage (items that are only visible when clicked on) will be included when printing or if they will remain hidden? ...

Acquire the current audio video stream directly from the web browser

Currently, I am utilizing a JavaScript library that internally invokes getUserMedia. My objective is to access the stream object that has already been initiated. Unfortunately, the library does not provide any means to retrieve it. Is there a method avai ...

What is the best way to align Bootstrap icons in the middle of buttons?

Currently, I am incorporating bootstrap icons into my design. Feel free to explore the provided DEMO. It showcases the issue of the bootstrap icons not aligning in the same line as the text inside the button. I am seeking advice on how to centralize the i ...

Transport parameter via routerLink to a different component

When I click on the link provided in the list-profile HTML document, I need to send a variable. However, the current code is not working and causing crashes. If more details are required, feel free to ask. List Profile Component HTML <div class="col c ...