Flexbox not achieving equal height

Having trouble making flexbox work with Susy? Here's what I've tried so far.

I've experimented with various solutions found here, but couldn't get it to work consistently across different screen sizes. The heights of text containers and image containers seem to break, especially on mobile views larger than 38em.

Whenever I apply display: flex to the items within the container, they appear in a single row instead of being stacked as intended.

I also noticed that I need to use display properties for the images as well...

Check out my code here

<div class="l-wrap-page">
    <!-- Start Main Content Wrapper -->
    <div class="l-wrap-main">
        <!--  Start Quote -->
        <div class="c-quote">
            <h2 class="c-quote__title">Quote</h2>
            <div class="c-quote__content">
                <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
            </div>
            <button class"o-btn">mehr</button>
        </div>
        <!-- End Quote -->
        <!-- Start Content Block -->
        <div class="c-block">
            <div class="c-block__item">
                <div class="o-media">
                    <img src="http://dummyimage.com/650x325/000/fff" alt="">
                </div>
            </div>
            <div class="c-block__item">
                ...

<p>CSS:</p>

<pre><code> ...

Answer №1

When you establish a flex container (display: flex or display: inline-flex), it automatically comes with various default settings. Here are some of them:

  • justify-content: flex-start - flex items will stack at the beginning of the line
  • flex-wrap: nowrap - flex items are constrained to remain in a single line
  • flex-shrink: 1 - flex items can shrink if necessary
  • align-items: stretch - flex items will stretch to cover the cross-size of the container
  • flex-direction: row - flex items will align horizontally

Take note of the last setting. To make your flex items stack vertically, you can override this default setting (on the container) by using flex-direction: column.

Alternatively, you could enable wrapping (flex-wrap: wrap) and assign enough width to each item to force it onto the next line. For instance, applying width: 100% to each item along with wrap on the container can generate a single column of flex items.

If you want more information on achieving equal height columns with flexbox, check out these resources:

  • Equal Height Columns with Flexbox
  • Equal height rows in a flex container

In this scenario, consider updating the .c-block rule in this manner:

Updated codepen

.c-block {
  display: flex;            /*  added property  */
  flex-wrap: wrap;          /*  added property  */
  -webkit-box-flex: 1;
      -ms-flex: 1;
          flex: 1;
}

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 preventing me from changing the text color of this span element to white?

For some reason, I'm trying to make the first two texts of each line appear in white, but my CSS doesn't seem to affect the span elements generated by JavaScript. Take a look at the code snippet below for more details. I'm still learning ho ...

Adjust the height of the card body to match the horizontal bootstrap 5 card image

Is there a way to use Bootstrap 5.1.3 to make the image fill the height of the card's body and footer, while also ensuring the card-footer is placed at the bottom of the card? The desired outcome: <link rel="stylesheet" href="https://cdn.jsdeli ...

Is there a way to ensure that HTML5 audio is responsive when using Bootstrap?

I need help with making my HTML5 audio player responsive in Bootstrap. Here is the code I currently have: <div class="col-sm-4 col-sm-offset-4"> <audio controls style="width: 600px;"> <source src="sample.mp3"> < ...

CSS method for creating designs surrounding text

I'm working on styling a section of a website with a pattern running alongside certain pieces of text. I've included a screenshot taken from the PSD file to illustrate the issue I'm facing, with red arrows indicating the areas that are posin ...

Trouble with search box images on Internet Explorer causing confusion

Here is the searchbox image displayed: With this code and css styling: #searchcontainer { margin: 40px 0 0 0; } .search { float: right; margin: 0; padding: 0; height: 21px; width: 310px; } .search input, .search button { mar ...

How can I make all fields in the CKAN Resource form html the same size as the "Description" field?

I am completely new to CKAN and front-end development. I've been scouring through various html/css files without success in locating where I can adjust the field sizes in the resources form (where users can modify metadata via GUI). I would like to r ...

HTML - Toggle visibility of div using display property

I'm currently working on implementing a show and hide functionality for a div. I followed a tutorial from a website called w3schools, but the way they implemented it is different from what I'm looking to achieve. In their example, the div is init ...

Create a scrollable horizontal list of items

I am encountering an issue with my mat chip list in Angular Material. I have a mat chip list filled with mat-chips that I want to display in a single row. If there are more items than can fit on the screen, I would like the area to be scrollable horizonta ...

Deleting a li element within an AJAX response function can be accomplished by targeting the specific

I am attempting to remove the li element that is the parent of the clicked a element. Here is the code I am using: function vanish(id_arg){ $.ajax({ url: "/vanish/", type: "POST", data: {id_to_delete: id_arg}, ...

The Bootstrap-Select dropdown refuses to open

I've been attempting to create a menu using data-subtext, and while I have come across some suggestions on stackoverflow, I'm still having trouble getting the menu to function properly. The issue I'm facing is that the menu doesn't seem ...

Android phone experiencing issues with custom search engine functionality

Google custom search is functioning correctly in the browser as well as in the emulator within Phonegap. However, on an Android phone, it encounters a network error or displays a blank screen. Sometimes, the error message "file:///google.com/cse?q=.... can ...

Position the button at the bottom right corner of the form

I created a basic webpage using Bootstrap 4 with a contact form and I am trying to figure out how to align the button to the bottom right instead of the bottom middle. Can anyone help me achieve this? https://i.sstatic.net/0Dnz1.jpg Below is the HTML cod ...

PHP-generated HTML often contains unnecessary and excessive indentation

I'm trying to adjust the indentation of my HTML generated by PHP, but I'm facing issues removing some unwanted indentations. Take a look at this snippet from the HTML source: <table id="structure"> <tr> <td id="navigation"> ...

When converting a block formatting context into a block, the margin does not collapse

It seems that the behavior of margins collapsing between block elements inside and outside a BFC is not as straightforward as expected. For instance, when a button element's display property is set to inline-block, it forms a BFC, which should prevent ...

What is the method for inserting a newline into a textarea with an HTTPRequest?

Is it possible to print a newline in a textarea using the HTTPRequest property? Here's the code I have: <script> function sendRequest(str) { var xmlhttp; if (window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); } el ...

Using JavaScript to transfer the data ID from a button to a form

I am working on a project where I have a button that triggers a modal: <button type="button" class="btn btn-primary add-subscription" data-toggle="modal" data-workspace_id="{{ workspace.id }}" data-target="# ...

Issue with rendering components list in React.js

I am currently working on a project using React, and I'm facing an issue where my list is not displaying on render(). In my parent component, I have a list of components coming from SearchResult. Below is the relevant portion of my code: class Create ...

Troubleshooting a Problem with CSS Div Multi-column Formatting

I have designed a multi-column div that displays correctly in Firefox but has formatting issues in Chrome and IE. In Firefox, the three columns appear properly with the frame of the last item in column one ending correctly. However, in Chrome and IE, the f ...

Revise Bootstrap accordion setup

I currently have a Bootstrap accordion set up on my website using Bootstrap 4.1.0 <div id="accordion" class="mt-3"> <div class="card"> <div class="card-header bg-dark text-white" id="headingOne"> <h5 class="mb-0 f ...

I am encountering an issue with opening a dropdown select option upon clicking in C# while using Selenium

I am encountering an issue while attempting to open the Register page from my account. The UI developer utilized Bootstrap code, and Bootstrap developers have included a JS function on click. However, when I execute this code, an error is thrown: "OpenQA.S ...