What is the best way to vertically align Bootstrap Columns to ensure they have consistent heights?

I'm currently in the process of building a website that features multiple images and content organized into columns using Bootstrap as the framework.

I'm wondering if there's a way to automatically adjust all the columns to the height of the row. Here's a snippet of my code:

<div class="row">
    <div class="col-md-6 col-xs-12">
        <img src="images/main.jpg" class="img-responsive" alt="" />

        <div class="slogan">
            <h1>WEBSITE TITLE.<br />SLOGAN.</h1>
        </div>
    </div>

    <div class="col-md-3 col-xs-6">
        <div class="box content">
            <h3>Services and Pricing</h3>
            <br />
            <a href="#" title="" class="btn btn-custom">READ MORE</a>
        </div>

        <img src="images/1.jpg" class="img-responsive" alt="" />
    </div>

    <div class="col-md-3 col-xs-6">
        <img src="images/2.jpg" class="img-responsive" alt="" />

        <div class="box content">
            <h3>Student Discount</h3>
            <br />
            <a href="#" title="" class="btn btn-custom">LEARN MORE</a>
        </div>
    </div>
</div>

In this example, I've noticed that the two "col-md-3 col-xs-6" columns do not match the height of the "col-md-6 col-xs-12" column.

Can anyone advise on how to make them align with the row's height so that all content appears uniformly?

Your help is greatly appreciated.

Answer №1

To ensure that all columns have the same height, you can utilize CSS flexbox. Here is an example of how you can modify your code:

<div class="row heightadjust">
    <div class="col-md-6 col-xs-12">
        <img src="images/main.jpg" class="img-responsive" alt="" />

        <div class="slogan">
            <h1>WEBSITE TITLE.<br />SLOGAN.</h1>
        </div>
    </div>

    <div class="col-md-3 col-xs-6">
        <div class="box content">
            <h3>Services and Pricing</h3>
            <br />
            <a href="#" title="" class="btn btn-custom">READ MORE</a>
        </div>

        <img src="images/1.jpg" class="img-responsive" alt="" />
    </div>

    <div class="col-md-3 col-xs-6">
        <img src="images/2.jpg" class="img-responsive" alt="" />

        <div class="box content">
            <h3>Student Discount</h3>
            <br />
            <a href="#" title="" class="btn btn-custom">LEARN MORE</a>
        </div>
    </div>
</div>

Make sure to add the following custom CSS:

.heightadjust {
    display: flex;
}

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

Is there a way to shift this modal to the right?

I am facing an issue with aligning a button modal to the right side. I attempted using bootstrap classes like : float:right, mt:20 Unfortunately, these did not have the desired effect. Below is my code snippet: <b-modal ref="my-modal" hide-fo ...

get direct access to the children of a specific div element

Here is the code snippet in HTML format. <div id="this"> <a href="xxx"> xx</a> <a href="yy"> yy</a> <a href="zzz"> zzz</a> aaa <a href="bbb"> bbb</a> ccc </div> I am look ...

Anchor links are functioning properly in browsers, yet they do not seem to work in HTML emails sent through Outlook

I am currently dealing with an HTML email that was generated from a Windows application. The template used for this email is designed in a .aspx page. One issue I have encountered is that the links at the top of the email, meant to take the user to a detai ...

Generate clickable links on a web page with PHP and a form

Every week I find myself tediously creating links by manually copying and pasting. It's starting to feel like a crazy process, and I'm sure there must be a faster way. A123456 B34567 d928333 s121233 I need these numbers to be transformed into h ...

Using VB.NET with Selenium to locate and interact with dropdown elements

My knowledge of selenium is limited, and I'm facing difficulty in selecting an element from a dropdown menu on AliExpress using vb.net. The issue arises when the driver either fails to locate the intended element or finds another element with the same ...

Changing the display of elements using Javascript in IE6 by modifying class

Currently, I am facing an issue at work that involves a piece of code. The code functions correctly in Firefox 3.6 where clicking on a row changes its class name and should also change the properties of the child elements. However, in IE6 and possibly othe ...

The setting "break-word" within word warp attribute isn't effective for formatting my text

Here is the CSS code that I am using: .SubjectCell{ width: 300px; padding-left: 3em; padding-right: 2em; color: black; font-size: 20px; word-wrap:break-word; } I have applied this class to a table cell within a table in my datalist: <td class ...

A flashy Rickshawgraph with the ability to modify the background color of the top data series

I am facing a challenge in modifying the background color of the rickshawgraph widget in dashing based on the maximum value of the highest graph from the latest incoming data. While I have successfully implemented this feature for one series, I am struggli ...

HTML form for selecting shipping method in PayPal

In my shopping cart setup, I offer two shipping methods: 'express' and 'standard'. I'm wondering if it's feasible to transmit this data to PayPal using HTML variables? ...

Adaptable Image Functionality in Jquery Carousel

I've encountered an issue with my images within a jquery slider. While the slider itself is functioning properly, I am facing a couple of challenges. Initially, I aimed to make the images responsive, but upon removing the height property, the content ...

Updating Navigation Bar Font

I am a novice in the process of constructing my own navigation bar for my website, and I am encountering difficulties when trying to customize the font (color, font-family, etc). Currently, the links in my navigation bar (such as home, contact, store, etc ...

Unable to access account: HTML Javascript login issue

Problem with Login Code As a newcomer to HTML, CSS, and almost unknown in Javascript, I sought help from others to create a login code. The code was working fine earlier, but now it's not functioning as expected. Despite checking everything, I can&ap ...

Place elements in a grid layout using CSS (and also ensure they are centered)

My goal is to create a data-grid (table layout) where the elements have fixed sizes. These elements should be placed in the same line until they can't fit anymore, then move to the next line. I have tried using inline-blocks for this, but I'm st ...

Interactive Div Updates Dropdown Selections Automatically

// function to add set of elements var ed = 1; function new_server() { ed++; var newDiv = $('#server div:first').clone(); newDiv.attr('id', ed); var delLink = '<a class="btn btn-danger" style="text-align:right;m ...

Retrieving the ID from the element that was clicked

Here is a code snippet that allows for the changing of color and text when an href link is clicked. /* Function to change the color of the button upon click */ function changeColor(element) { alert(element.target.id); if (element.innerHTML == "Selec ...

I am unable to switch my carousel to full-screen mode

I'm struggling to make the carousel fullscreen even though I've set the width to 100%. Bootstrap was used in this project. Any help would be appreciated. Thank you! <html> <head> <link href="homepage.cs ...

Creating a multi-level JSON object from a string: A step-by-step guide

I've organized my HTML file in the following structure: Chapter 1.1 1.1.1 interesting paragraph 1.1.1.1 interesting paragraph Chapter 1.2 1.2.1 interesting paragraph 1.2.1.1 interesting paragraph ... Chapter 11.4 ... 11.4.12 interesting ...

Compatibility discrepancies for object-fit: cover as per observations from Mozilla and caniuse

I'm curious about the browsers that support the CSS property object-fit: cover. My usual sources for checking compatibility are the Mozilla browser compatibility table and caniuse, but they sometimes provide conflicting information. For example, while ...

Could this be the most straightforward and versatile method for vertically centering text inside a block element?

Discovering something new in the world of coding is always exciting: HTML: <div>Vertically Centered Text<span></span></div> CSS: div { height: 100px; /* adjust as needed */ } div > span { display: inline-block; v ...

Why is it not possible for me to choose an element after it has been placed within a grid component?

Struggling to eliminate the blur effect on an image inside a grid element? It seems modifying the properties of an element within a grid class is causing some issues. To simplify, I conducted a basic test: I managed to change the ppp2 class when hovering ...