Ensure that the rows in various Flexbox columns have uniform heights

I need to organize my content into three columns using Flexbox, similar to pricing plans.

However, the challenge is that each column contains multiple rows of text with varying lengths. Is there a way to ensure that all rows in each column have the same height?

<div class="outer">
  <div class="column">
    <div class="text">Some text</div>
    <div class="text">Some text</div>
    <div class="text">Some text more than</div>
    <div class="text">Some text</div>
    <div class="text">Some text</div>
    <div class="text">Some text more than</div>
    <div class="text">Some text</div>
    <div class="text">Some text</div>
    <div class="text">Some text more than</div>
  </div>
  <div class="column">
    <div class="text">Some text</div>
    <div class="text">Some text</div>
    <div class="text">Some text others</div>
    <div class="text">Some text</div>
    <div class="text">Some text</div>
    <div class="text">Some text more than</div>
    <div class="text">Some text</div>
    <div class="text">Some text</div>
    <div class="text">Some text more than</div>
  </div>
  <div class="column">
    <div class="text">Some text</div>
    <div class="text">Some text</div>
    <div class="text">Some text</div>
    <div class="text">Some text</div>
    <div class="text">Some text</div>
    <div class="text">Some text more than dsd sdsd d d</div>
    <div class="text">Some text</div>
    <div class="text">Some text</div>
    <div class="text">Some text more than</div>
  </div>
</div>



.outer {
  display: flex;
  height: 700px;
}

.column {
  display: flex;
  algin-items: stretch;
  margin-right: 15px;
  background-color: green;
  flex-direction: column;

}

.text {
  background: red;
  width: 50px;
  margin: 5px;
}

Although I cannot utilize CSS grid, I still want to achieve a structure similar to the example provided. This means ensuring that all rows in each column have the same height but are enclosed within different "column" wrappers.

Example

https://i.sstatic.net/NaIPT.png

Answer №1

Have you ever considered approaching this from a different angle and creating flex rows instead? Check out the example here

Then, you can adjust the widths of the flex items as needed to give the illusion of columns.

HTML

<div class="outer">
  <div class="row">
    <div class="text">Some text</div>
    ...
    <div class="text">Some text more than</div>
  </div>
  <div class="row">
    <div class="text">Some text</div>
    ...
    <div class="text">Some text more than</div>
  </div>
  <div class="row">
     <div class="text">Some text</div>
    ...
    <div class="text">Some text more than</div>
  </div>
</div>

** CSS **

.outer {
/*   display: flex; */
/*   height: 700px; */
/*   flex-direction:column; */
}

.row {
  display: flex;
/*   algin-items: stretch; */
  margin-right: 15px;
  background-color: green;
  width:180px;
  flex-wrap:wrap
}

.text {
  background: red;
  width: 50px;
  margin: 5px;
}

While it's a nice idea, I do need the rows to be responsive...

You could also explore another approach: Take a look at this alternative idea

Alternatively, have you considered using CSS tables for your content?

I hope these suggestions help!

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 best way to create a responsive navigation bar design?

I'm trying to create a unique navigation bar that features a hexagon-shaped logo and 3 buttons aligned in a specific way. Check out the screenshot for reference here. Although I've managed to align everything perfectly on a fullscreen (1920x1080 ...

Breaking down a jQuery array into separate JSON objects

Hi there, I am currently working on constructing a post request. Here is the format I need to send: const data = { categories: [ { id: 9 }, { id: 14 } ], } However, what I have is ["29", "23", "22&quo ...

Limit certain website functions exclusively for members

I am currently working on a website that offers a set of basic features for all users, along with some exclusive features reserved for members. For example, all visitors can read posts, but only members have the ability to add tags, share posts, and more. ...

Choosing an option in react-select causes the page to unexpectedly shift

Encountering a problem with a mobile modal developed using react-select. The selectors are within a div with fixed height and overflow-y: scroll. Upon selecting an option for the 'Choose observer' select, the entire modal briefly jumps down in th ...

CSS clearfix restricted to immediate parent div

Below is the code snippet that illustrates the objective I am attempting to achieve <div> <div style="float:left; width:220px; height:300px; border: 1px solid #aaa"> Left div <br>float:left <br> fixed width 220px </div> ...

Manipulating a selected option using JavaScript

///////////////////////////////////////////////////////////////////////////// Below is the code I've written, and when I click the button to display the output from the function, nothing appears. Sample HTML Code <!DOCTYPE html> <html> ...

Close the space between the image and the Container

Looking at the image, you can view the demo http://jsfiddle.net/yJUH4/8/ Upon observing the picture, a slight gap appears between the image and the Container. The image already has the css property vertical-align:middle. When I increase the height of the ...

The vertical drop-down menu is displaying and functioning incorrectly

My vertical submenu is positioned correctly, but the links are overlapping on top of each other. The submenu doesn't hide when hovering over the main menu, but it does hide when hovering outside the menu. I'm unsure of what changes or additions t ...

Mobile phone web development using HTML5

I am currently facing an issue with playing sound on mobile browsers. In my code snippet, I have the following: Response.Write("<embed height='0' width='0' src='Ses.wav' />"); While this works perfectly fine on desktop ...

Is there a way to change the input type=file value?

What is the best method for customizing a file upload using input type="file" in HTML? Here is an example of what I am trying to achieve: <form enctype="multipart/form-data" action="xmlupload" method="post" name="form1" id="form1"> <input type ...

Python Selenium is unable to perform a loop in its automation tasks

I have a coding project where I am trying to extract original movie titles from a website. The manual input test version works fine, but when I attempt to create a loop that searches for titles from a list, I encounter some issues. Below is the complete co ...

Maximizing the potential of image srcset in HTML5

After configuring the img srcset as shown below: <img srcset="http://via.placeholder.com/320x150 320w, http://via.placeholder.com/480x150 480w, http://via.placeholder.com/800x150 800w" src="http://via.placeholder.com/8 ...

Utilize viewport activation to determine browser width

Is there a way to dynamically add the viewport-meta tag only for devices with screen widths larger than 680px? If the screen is smaller than 680px, then the responsive style file should be enabled instead. I attempted to achieve this by placing the follow ...

Learn the process of updating a specific section of a Facebook share link using AJAX dynamically

Here's an interesting scenario I'm dealing with. I'm trying to create a modification to the Facebook share button link where a portion of the link is replaced by a user ID number. This way, when someone clicks on the shared link, it will dir ...

Tips for incorporating a simple jQuery table

Is there a way to incorporate a simple table with 2 columns and 10 rows on a specific section of a webpage? The table will consist of 10 dynamic entries that are refreshed manually from the back-end DB. The second column of each entry will contain a bit.ly ...

What is the process for implementing an image as the background instead of a color for each column in a Google chart?

I'm currently working with Google Chart and I have set up a column chart. However, I am looking to display a background image instead of a background color in each column. Is this achievable with Google Chart? If so, how can I accomplish this? If anyo ...

Is it possible to animate background position using jQuery in fragments?

I'm attempting to utilize jQuery in order to gradually move the background position of my span 10 pixels downwards every second. Can anyone provide guidance on how to achieve this successfully? Despite experimenting with jQuery animate, delay, CSS, a ...

CSS menu that is activated on click

I'm currently working on creating a responsive menu, but unfortunately, I'm facing issues with getting the menu to open. Any assistance or advice would be greatly appreciated. <navi> <div class="gizli"><i class="fa fa ...

Is there a way to switch the video source when a particular h3 tag is clicked?

https://i.sstatic.net/I2gIZ.jpgI'm currently working on building a video streaming site, but I've hit a roadblock. My challenge right now is figuring out how to make the episode selector change the video player's source. I'm a bit conf ...

Adjust the color of radio button text with Jquery

Here is a sample of radio buttons: <input type='radio' name='ans' value='0'> Apple <input type='radio' name='ans' value='1'> Banana <input type='radio' name='ans&apo ...