Let ALL blocks of the same size using only CSS do not know if it is possible (unknown) since each line becomes independent, but each element of a line has a certain connection and can be used as parameter to keep all others (of the same line) of the same size.
The easiest way to achieve this result is by using Flex:
ul{
list-style: none;
padding: 0;margin: 0;
display: flex;
flex-wrap: wrap;
}
li{
width: 25%;
border: 5px solid black;
margin: 5px;
padding: 3px;
}
<ul>
<li>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</li>
<li>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Commodi rerum doloremque laborum? </li>
<li>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</li>
<li>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Et quasi corporis sed fugit quibusdam, possimus ipsam animi ab molestias. Eos qui id sint mollitia amet officiis, commodi natus officia libero.</li>
<li>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</li>
</ul>
the display: flex
by default will already leave all elements with the same size, but you lose control over their width it will try to leave everything in the same line, disregarding the defined width or limits of the page or parent element, which can be solved using the flex-wrap
, that allows you to break the line as soon as the elements pass the screen.
There is an alternative, but it does not solve 100%.
place your css and html code
– MagicHat
LI CSS: width: 200px; position: relative; height: 100%; border: 1px Solid #ccc; padding: 5px; text-align: center; display: inline-block;
– user7438004
As far as I know
height: 100%
only works if the upper parts have defined height.– KillerJack
put your code so we can help
– andrepaulo
Of all CSS-only lines I don’t know if it’s possible, but leaving the same size per line you can achieve using
flex
.– Pliavi