Expanding elements with Flexbox and Bootstrap 4: Strengthening the height to fill the remaining space

I have a row with three columns, each containing an image and a title.

Currently, on a large screen, the titles are displayed on a single line and everything looks fine.

However, when resizing the screen, the first title wraps onto two lines:

My goal is to make the other two titles stretch to match the height of the first title and be vertically centered:

Is there a way to achieve this using flexbox?

I have tried various solutions found when searching for "flexbox stretch/fill height", but none worked when I attempted to adapt them to my code. I attempted wrapping the content of each column in a div with display:flex and flex-direction:column, and placing the titles in a div with flex:1, but without success.

HTML CODE:

<section id="home_univers">
    <div class="container">
        <div class="row">
            <div class="col-lg-4">
                <img alt="Pet Animals" src="http:/placehold.it/450x210" alt="">
                <div class="test"><h3 class="bg_rose">aaaaaaa aa aaaaaaaaa</h3></div>
            </div>
            <div class="col-lg-4">
                <img alt="Horses" src="http:/placehold.it/450x210" alt="">
                <div class="test"><h3 class="bg_vert">aaaaaaa</h3></div>
            </div>
            <div class="col-lg-4">
                <img alt="Livestock" src="http:/placehold.it/450x210" alt="">
                <div class="test"><h3 class="bg_blue">aaaaaaa aa aaaaa</h3></div>
            </div>
        </div>
    </div>
</section>

CSS CODE:

.blue {
  color: #0033a0;
}

.bg_blue {
  background-color: #0033a0;
}

.rose {
  color: #ff7a6d;
}

.bg_rose {
  background-color: #ff7a6d;
}

.vert {
  color: #8dad20;
}

.bg_vert {
  background-color: #8dad20;
}

#home_univers {
  padding-top: 85px;
  padding-bottom: 85px;
}

#home_univers h3 {
  text-transform: uppercase;
  color: #fff;
  font-size: 24px;
  text-align: center;
  padding-top: 15px;
  padding-bottom: 15px;
  margin-bottom: 0;
}

#home_univers img {
  width: 100%;
}

JS Fiddle: https://jsfiddle.net/owvs550p/

Answer №1

HTML

<section id="home_univers">
    <div class="container">
        <div class="row">
            <div class="col-4">
                    <img alt="Pets" src="http:/placehold.it/450x210" alt="">

            </div>
            <!-- /.col-lg-4 -->
            <div class="col-4">
                    <img alt="Horses" src="http:/placehold.it/450x210" alt="">

            </div>
            <!-- /.col-lg-4 -->
            <div class="col-4">
                    <img alt="Livestock" src="http:/placehold.it/450x210" alt="">

            </div>
            <!-- /.col-lg-4 -->
        </div>
        <div class="row">
            <div class="col-4 color">


                    <div class="test  bg_rose"><h3 class="">aaaaaaa aa aaaaaaaaa</h3></div>
            </div>
            <!-- /.col-lg-4 -->
            <div class="col-4 color">

                <div class="test bg_vert"><h3 class="">aaaaaaa</h3></div>
            </div>
            <!-- /.col-lg-4 -->
            <div class="col-4 color">

                    <div class="test bg_blue"><h3 class="">aaaaaaa aa aaaaa</h3></div>
            </div>
            <!-- /.col-lg-4 -->
        </div>
        <!-- /.row -->
    </div>
    <!-- /.container -->
</section>

CSS

@import url('https://fonts.googleapis.com/css?family=Lato:400,700,900');

.orange {
    color: #ffba00;
}

.bg_orange {
    background-color: #ffba00;
}

.blue {
    color: #0033a0;
}

.bg_blue {
    background-color: #0033a0;
}

.rose {
    color: #ff7a6d;
}

.bg_rose {
    background-color: #ff7a6d;
}

.vert {
    color: #8dad20;
}

.bg_vert {
    background-color: #8dad20;
}

#home_univers {
    padding-top: 85px;
    padding-bottom: 85px;
}

#home_univers h3 {
    text-transform: uppercase;
    color: #fff;
    font-size: 24px;
    text-align: center;
    padding-top: 15px;
    padding-bottom: 15px;
    margin-bottom: 0;
}
#home_univers img {
    width:100%;
}
.col-4.color {
  display: flex;
}
.test {
      flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

Making a floating action button in Ionic

I am currently working on creating an action floating button using the Ionic framework. While I have successfully created a basic button, I am now looking to add some stylish effects and make additional buttons appear upon interaction. I understand that th ...

Node-modules CSS

In my React application, I am utilizing CSS modules. By configuring modules:true in my webpack.config.js, I can successfully apply styles from files within my src folder. However, when importing components from node-modules, the corresponding CSS is not be ...

Adjust div to match the size of the browser window

Looking to design a div that adjusts to the browser window size while allowing content below to be visible as the user scrolls. Preferably, the div should not be fixed, but rather adjust in size along with the browser window when resized. I'm confid ...

Setting the line-height property in CSS to a value greater than the font-size property

Dealing with a frustrating issue where I want to align the top of an image with text, but the letters end up slightly below the line height. Check out this simple example featuring a classic movie: HTML: <img src="http://cf2.imgobject.com/t/p/w92/wcI ...

What techniques can be employed to create a fully operational web application using AngularJS?

I have taken on the challenge of understanding AngularJS by creating a webapp. Within my Eclipse environment, I am working with 4 files: main.js, index.html, view1.js, and view2.html. Currently, I can get index.html to load when Tomcat is running. Embedd ...

What causes variations in the output of getClientRects() for identical code snippets?

Here is the code snippet provided. If you click on "Run code snippet" button, you will see the output: 1 - p.getClientRects().length 2 - span.getClientRects().length However, if you expand the snippet first and then run it, you will notice a slight dif ...

Ways to conceal #div element from displaying in the href attribute within the anchor tag

My anchor tag has an href attribute that looks like this: <a onclick='loadReview(\"" + strexternalURL + "\");' href='#productName1'. When clicking on it, the URL appears as http://localhost:54986/Dealerlist.aspx#productName ...

What could be causing the second image to not drop in the proper position in an HTML and JavaScript environment?

I am encountering an issue with a simple drag and drop implementation using images in my code. The first image works fine, but for some reason the second image does not display correctly when dragged inside the div boxes; it appears outside of the box. Can ...

Implementing a backdrop while content is floating

I am facing an issue with a div that has 2 columns. The height of the left column is dynamically changing, whereas the right column always remains fixed in height. To achieve this, I have used the float property for both column divs within the container di ...

Changing the class of a div in JavaScript from one class to another

On my HTML page, I have a div with a CSS class assigned to it. The goal is to switch the current class for another when a button is clicked. It's crucial that not a single CSS property within the class is altered - the entire class must be replaced en ...

Having issues transferring values from one page to another. Any suggestions to make it work correctly?

I currently have two pages within my website, one is called details.page and the other is maps.page. In the details page, I have set up a search input as shown below : <form method="get" id="form-search" data-ajax="true" action="maps.page"> ...

What is preventing the mat-slide-toggle from being moved inside the form tags?

I've got a functioning slide toggle that works perfectly, except when I try to move it next to the form, it stops working. When placed within the form tag, the toggle fails to change on click and remains in a false state. I've checked out other ...

Conceal a div element using a button through JavaScript

I've been scouring various online resources for solutions, including Stack Overflow and W3Schools, but I haven't had any luck so far. Here's a simplified version of my current code: <script language="javascript"> function remove() ...

CSS tricks: Make triangles stand out with unique hover effects

I find myself in a bit of a conundrum! I want to incorporate cursor: pointer into my CSS, but the issue is that it's for a triangle shape. If I were to use the following code: #triangleholder { width: 100px; height: 100px ...

Detecting collisions using CSS animation

I'm currently working on a unique "game" project. Check out the code snippet here: jsfiddle function update() { coyote.applyForce(gravity); coyote.edges(); coyote.update(); cactus.update(); if (coyote.intersects(cactus)){ alert("colisio ...

Tips for limiting access to data from various tabs when the web page first loads

div#tabCtrl div#page1 This table showcases the information for tab1 div#page2 This table showcases the information for tab2 ...

Is there a way to adjust the transparency of individual words in text as you scroll down a page, similar to the effect on https://joincly

Is there a way to achieve a text filling effect on page scroll similar to the one found here: . The specific section reads: "Deepen customer relationships. Own the brand experience. Add high margin revenue. Manage it all in one place. Get back your pr ...

The partnership between Selenium and WhitePages has created an innovative solution

I am currently attempting to register on . The registration process requires entering my first name, last name, email address, and password. For the first name field, I attempted to locate the element by CSS using the syntax "input#name_fname", however, I ...

Design a personalized select element with a unique background hue

https://i.stack.imgur.com/Dzifp.jpg Trying to create a navigation with col-md-9 and select tags but facing an issue where adding a background-color to the div causes the green background of the arrow to disappear. https://i.stack.imgur.com/A4P9Q.png Plea ...

Steps to prepend a domain to file_get_contents function in PHP script

Recently, I enlisted the help of a PHP coder to make modifications to two files for me. The purpose was to allow users to link directly to a file converted from DOC to IMG on . Below you can find the edited code (highlighted by 'DrTech76'): get ...