Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List items with same height

Tags:

html

css

I have created a fiddle: http://jsfiddle.net/pQZ8f/

I want to have both the list items to be of same height without setting height manually. I want it to auto grow. I don't want to use javascript. Can it done be through css?

like image 785
emphaticsunshine Avatar asked Sep 07 '12 20:09

emphaticsunshine


People also ask

How do you make all your Li the same height?

Adding class ="frame-height" to all li elements, make all li elements the same height as the highest li element.

How do I keep two side by side DIV elements the same height?

The two or more different div of same height can be put side-by-side using CSS. Use CSS property to set the height and width of div and use display property to place div in side-by-side format. The used display property are listed below: display:table; This property is used for elements (div) which behaves like table.

How do you make a DIV the same height as another?

Place both DIVs into a container DIV that's set to 100% of page height and set both interior DIVS to 100%. They will fill up the container DIV and the height of both will be equal.

How do I make bootstrap 4 columns equal height?

You just have to use class="row-eq-height" with your class="row" to get equal height columns for previous bootstrap versions.


2 Answers

It's 2018, and we have display: flex, with 97.66% browser support (https://caniuse.com/#feat=flexbox)

With flexbox, all you need to do is:

ul {
  display: flex;
}

li{
 width:100px;
 border: 1px solid black;   
}

Here's the fiddle: http://jsfiddle.net/pQZ8f/1076/

like image 106
Palash Karia Avatar answered Sep 23 '22 14:09

Palash Karia


It seems you're looking for a tabular layout, so maybe the best bet would be to use a <table> instead of floating <li> elements.

That said, you can also specify tabular styles on your elements:

ul {
    display: table-row;
}

li {
    width: 100px;
    border: 1px solid black;
    display: table-cell;
}

This should work on most modern browsers. You will find an updated fiddle here.

like image 27
Frédéric Hamidi Avatar answered Sep 20 '22 14:09

Frédéric Hamidi