Reputation: 11
I want to display the items in html as below:
1 4 7
2 5 8
3 6
I tried using the following code:
this displays all the items in one column. It should be displayed in 3 rows. HTML code
#limheight {
height: 300px; /*your fixed height*/
-webkit-column-count: 3;
-moz-column-count: 3;
column-count: 3; /* in those rules is just placeholder -- can be anything*/
}
#limheight li {
display: inline-block; /*necessary*/
}
<ul id = "limheight">
<li>
<span class="oj-typography-body-xs oj-text-color-secondary">"1"</span><br>
<span class="oj-typography-body-xs oj-text-color-secondary">"2"</span><br>
<span class="oj-typography-body-xs oj-text-color-secondary">"3"</span><br>
<span class="oj-typography-body-xs oj-text-color-secondary">"4"</span><br>
<span class="oj-typography-body-xs oj-text-color-secondary">"5"</span><br>
</li>
</ul>
<li>
Upvotes: 0
Views: 98
Reputation: 1435
#limheight {
height: 300px; /*your fixed height*/
}
#limheight li {
display: flex;
flex-wrap: wrap;
}
ul {
width: 100%;
}
span {
flex: 0 0 33.33%;
}
<ul id = "limheight">
<li>
<span class="oj-typography-body-xs oj-text-color-secondary">"1"</span>
<span class="oj-typography-body-xs oj-text-color-secondary">"2"</span>
<span class="oj-typography-body-xs oj-text-color-secondary">"3"</span>
<span class="oj-typography-body-xs oj-text-color-secondary">"4"</span>
<span class="oj-typography-body-xs oj-text-color-secondary">"5"</span>
<span class="oj-typography-body-xs oj-text-color-secondary">"6"</span>
</li>
</ul>
You can make span's height to "300px", if you want their height "300px";
Upvotes: 1
Reputation: 1537
.grid-container {
display: grid;
grid-template-columns: auto auto auto;
background-color: #2196F3;
padding: 10px;
}
.grid-item {
background-color: rgba(255, 255, 255, 0.8);
border: 1px solid rgba(0, 0, 0, 0.8);
padding: 20px;
font-size: 30px;
text-align: center;
}
<div class="grid-container">
<div class="grid-item">1</div>
<div class="grid-item">2</div>
<div class="grid-item">3</div>
<div class="grid-item">4</div>
<div class="grid-item">5</div>
<div class="grid-item">6</div>
<div class="grid-item">7</div>
<div class="grid-item">8</div>
<div class="grid-item">9</div>
</div>
Upvotes: 1