How can I set groups of three list items to be the same height as the tallest?

equal height columns flexbox
css equal height rows
make two divs side by side same height bootstrap
equal height divs css
equal height columns bootstrap
bootstrap 4 equal height
css equal height columns responsive
css grid equal height columns

I have three columns of text in a tabular format. They are populated from a JSON feed. How can I set every row of three LI elements to be the same height as the tallest in that row?

Do I need jQuery or can I just use CSS?

I want it to behave how a HTML TABLE does, but without changing the Javascript which interprets the JSON feed to make it iterate through the elements in groups of three. Thanks!

ul {
  width: 600px;
}

li {
  display: block;
  width: 180px; 
  padding: 10px;
  margin: 0; 
}

/* Makes the first cell in each row float right and the second one go left */

li:nth-child(3n+1) {
  float: right;
  clear: right;
}

li:nth-child(3n+2) {
  float: left;
  clear: left;
}
<ul>
  <li>This is cell #1, which should appear top right</li>
  <li>Cell #2, top left</li>
  <li>Cell #3 is top centre, and will be the tallest of the cells, as it contains the most text. I would like this row to be of equal height.</li>
  <li>Cell #4, populated from the JSON feed is 2nd row right.</li>
  <li>Cell #5, 2nd row left</li>
  <li>Cell #6 should display 2nd row centre.</li>

<!-- Arbitrarily large number of LI cells to follow here, 
  in three columns, as they are populated from a JSON feed, 
  which I have not included as I feel it over-complicates a
  question about HTML, CSS and jQuery layout -->

</ul>

I have used CSS Grid in my answer.

For more info: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout

.container {
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: minmax(100px, auto);
}

.container > li {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.top-left {
  grid-column: 1;
  grid-row: 1;
}

.top-center {
  grid-column: 2;
  grid-row: 1;
}

.top-right {
  grid-column: 3;
  grid-row: 1;
}

.bottom-left {
  grid-column: 1;
  grid-row: 2;
}

.bottom-center {
  grid-column: 2;
  grid-row: 2;
}

.bottom-right {
  grid-column: 3;
  grid-row: 2;
}

li:nth-child(6n+1), li:nth-child(6n+2), li:nth-child(6n+6) {
  background: #000;
  color: #fff;
}

li:nth-child(6n+3), li:nth-child(6n+4), li:nth-child(6n+5) {
  background: #fff; 
  color: #000;
}
<ul class="container">
  <li class="top-right">This is cell #1, which should appear top right</li>
  <li class="top-left">Cell #2, top left</li>
  <li class="top-center">Cell #3 is top centre, and will be the tallest of the cells, as it contains the most text. I would like this row to be of equal height.<br>EQUAL HEIGHT<br>EQUAL HEIGHT<br>EQUAL HEIGHT<br>EQUAL HEIGHT<br>EQUAL HEIGHT<br>EQUAL HEIGHT<br>EQUAL HEIGHT<br>EQUAL HEIGHT<br>EQUAL HEIGHT<br>EQUAL HEIGHT<br></li>
  <li class="bottom-right">Cell #4, populated from the JSON feed is bottom right.</li>
  <li class="bottom-left">Cell #5, bottom left</li>
  <li class="bottom-center">Cell #6 should display bottom centre.</li>
</ul>

How To Create Equal Height Columns, When you have columns that should appear side by side, you'll often want them to be of equal height (matching the height of the tallest). The Problem: The Desire​:. • Then give your child 3 cups of diff erent heights and have him or her order them from shortest to tallest. Ask which cup is the shortest and which cup is the tallest. • Help your child fi nd one more set of objects that can be ordered by length or height. For example, your child might suggest hair clips, ribbons, trophies, or books.


In your CSS, change li {display: block;} to li {display: table-cell;}. This should do the trick.

Fluid Width Equal Height Columns, THE PROBLEM: Three columns with different amounts of content only grow as tall as THE DESIRE: Columns are all equally tall, matching the height of the tallest. to simulate the look of equal height columns, even if the elements themselves <div class="five-columns group"> <div class="col"><p>​Pellentesque habitant  How to Display Small Items on a Table. Variety in height creates visual interest. Groups of three or five items are usually more aesthetically pleasing than groups of two or four. 3.


Here is a preview of the power of the grid,

You can check the website can I use, and for be cross browser is no so bad.

Can I use flexbox

Here is a modification, to manage the height just use flex.

The order you can alter it with jquery. just because I guess it will be a pattern.

Let me know how did you go!

:) Happy Friday

      ul {
        width: 600px;
        display:flex;
        flex-wrap: wrap;
      }

      li {
          display: block;
          width: 33%; 
          margin: 0; 
          padding: 10px; 
          font-size: 12px;
              box-sizing: border-box;
        }
    
        /* Causes the text and background colours to pattern to alternate in cells */



      li:nth-child(6n+1), li:nth-child(6n+2), li:nth-child(6n+6) {
          background: #000;
          color: #fff;
        }

      li:nth-child(6n+3), li:nth-child(6n+4), li:nth-child(6n+5) {
          background: #fff; 
          color: #000;
        }

        /* Makes the first cell in each row float right and the second one go left */
      
    <div id="checkerboard">

      <ul>

        <li>This is cell #1, which should appear top right</li>

        <li>Cell #2, top left</li>

        <li>Cell #3 is top centre, and will be the tallest of the cells, as it contains the most text. I would like this row to be of equal height.</li>

        <li>Cell #4, populated from the JSON feed is bottom right.</li>

        <li>Cell #5, bottom left</li>

        <li>Cell #6 should display bottom centre.</li>
</ul>
    </div>

Everything You Need To Know About Alignment In Flexbox , So the ability to properly align items and groups of items was for many This means that we can use the same alignment properties in CSS Grid Three Three Three as a column, and I have set the height of the flex container to 60vh . The reason that flex items appear to stretch to the size of the tallest  With CSS you could only have a new "row" using clearfix class (as answered before), but each div will have different height. If you wish to set the same height to each dynamic div, I think you could do it only by js.


Scientific American: Supplement, So this music that comes to us from the North has been refined and put in The symphony of Russian airs is not the same as ours. This instrument has but three strings, two of which give the mi and the third the The increased frequency of the Teutonic element in the \Vestern group probably accounts for the taller height,  To play, divide participants into groups of three or four and give each group 20 sticks of dry spaghetti, a long piece of string, some tape and a marshmallow. The goal is to see which team can build the tallest structure with the marshmallow on top of the finished product.


What Happens When You Create A Flexbox Flex Container , In order to use Flexbox, you need an element that will be the flex container. The children of our inline flex container behave in the same way that list-style: none; all stretch to the height of the tallest, then setting align-items: flex-start However, in the first screenshot, the third box has a smaller amount  A user-defined code (system 41/type 01) that identifies a group of items that share the same size specifications, such as height and width. An item dimension group defines the size specifications for all items that belong to the group. After you set up an item dimension group, you can assign items to the group through Classification Codes.


Auto-placement in CSS Grid Layout, In addition to the ability to place items accurately onto a created grid, the CSS Grid Layout in action in the simplest of ways by creating a grid on a set of items. of rows that are a minimum size but then grow to fit content if it is taller. with grid-auto-columns , this works in the same way as grid-auto-rows . If you're unsure, start with groups of three, and arrange items on the shelf in order from left to right: tall piece, heaviest piece, tall piece. Or, copy that same pattern on alternating shelves with two tall pieces on the top shelf, the heaviest piece centered on the shelf directly below it and two tall pieces on the shelf below that.