Reputation: 83
I need to make a div and it has 3 columns in the first, let's say 5 lines, in the second column also 5 lines and in the third 3 lines, but I need to make these 3 lines stretch to the full height
It should be like this
I tried
.base {
/*make it 100% width and a minimum of 1000px width*/
width: auto;
margin-left: 0px;
margin-right: 0px;
min-width: 1000px;
padding: 0px;
display: table;
}
.base-row {
Display: table-row;
}
.base li {
display: table-cell;
width: 33%;
}
.cell1 {
background-color: #f00;
}
<div class=”base”>
<ul class=”base-row”>
<li class="cell1">
<div class="content1">.....Lots of Content....</div>
</li>
<li class="cell1">
<div class="content2">.....Lots of content....</div>
</li>
<li class="cell1">
<div class="content3">.....Lots of content....</div>
</li>
</ul>
</div>
Upvotes: 0
Views: 2077
Reputation: 1519
* {
margin: 0;
padding: 0;
}
.container {
max-width: 991px;
display: flex;
}
.col {
width: 33.3%;
display: flex;
flex-direction: column;
}
.col div {
border: 1px solid #000;
flex-grow: 1;
padding: 20px 0;
text-align: center;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<div class="container">
<div class="col">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
</div>
<div class="col">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
</div>
<div class="col">
<div>1</div>
<div>2</div>
<div>3</div>
</div>
</div>
</body>
</html>
Use flex-grow: 1
on the div that you wanted to be stretched. Hope it'll help
Upvotes: 0
Reputation: 10834
You can use flex to style your layout. Set display: flex
to the container, then set each column with
flex-grow: 1;
flex-basis: 0;
flex-shrink: 0;
This will make sure the columns will have equal width. Then set
display: flex;
flex-direction: column;
To each column, it will arrange the elements inside vertically. Also set
flex-grow: 1;
flex-basis: 0;
flex-shrink: 0;
to the rows and add as many rows as you want in each column.
.cont{
display: flex;
width: 100%;
}
.col{
flex-grow: 1;
flex-basis: 0;
flex-shrink: 0;
display: flex;
flex-direction: column;
}
.row{
flex-grow: 1;
flex-basis: 0;
flex-shrink: 0;
border: 1px solid black;
padding: 10px;
}
<div class="cont">
<div class="col">
<div class="row">1</div>
<div class="row">2</div>
<div class="row">3</div>
<div class="row">4</div>
<div class="row">5</div>
</div>
<div class="col">
<div class="row">a</div>
<div class="row">b</div>
<div class="row">c</div>
<div class="row">d</div>
<div class="row">e</div>
</div>
<div class="col">
<div class="row">111</div>
<div class="row">222</div>
<div class="row">333</div>
</div>
</div>
Upvotes: 1