Home > database >  css - responsive layout having only two columns instead of five
css - responsive layout having only two columns instead of five

Time:11-27

a grid with five columns
col_space are equal and flexible and they are just for space
col_1 and col_2 are content columns and fixed size
question - can I have the same funcionality without col_space at all ?

just like this:

<div class='wrap'>
<div class='col_1'>lorem</div>
<div class='col_2'>ipsum</div>
</div>

.wrap{
display:grid;
grid-template-columns:1fr 99px 1fr 54px 1fr;
height:50vh;
}

.col_space{background:lightblue;}
.col_1, .col_2{background:orange;}
<div class='wrap'>
<div class='col_space'></div>
<div class='col_1'>lorem</div>
<div class='col_space'></div>
<div class='col_2'>ipsum</div>
<div class='col_space'></div>
</div>

CodePudding user response:

space-evenly on justify—content will do this,

.wrap{
display:grid;
grid-template-columns:99px 54px;
height:50vh;
justify-content: space-evenly;
}

.wrap{background:lightblue;}
.col_1, .col_2{background:orange;}
<div class='wrap'>
<div class='col_1'>lorem</div>
<div class='col_1'>ipsum</div>
</div>

  • Related