CSS Grid: Use CSS Grid units to Change the Size of Columns and Rows
You can use absolute and relative units like
px and em in CSS Grid to define the size of rows and columns. You can use these as well:fr: sets the column or row to a fraction of the available space,auto: sets the column or row to the width or height of its content automatically,%: adjusts the column or row to the percent width of its container.
1
2
3
4
5
html code for these grid
html code for these grid
<style> .d1{background:LightSkyBlue;} .d2{background:LightSalmon;} .d3{background:PaleTurquoise;} .d4{background:LightPink;} .d5{background:PaleGreen;} .container { font-size: 40px; width: 100%; background: LightGray; display: grid; grid-template-columns: auto 50px 10% 2fr 1fr; grid-template-rows: 50px 50px; } </style> <div class="container"> <div class="d1">1</div> <div class="d2">2</div> <div class="d3">3</div> <div class="d4">4</div> <div class="d5">5</div> </div>
source
Comments
Post a Comment