I am trying to do a layout using CSS where I have a grid of 2 columns and 2 rows.
The first column should have a width of 1fr
and the second column 4fr
.
I tried using auto-fit
:
HTML
<body>
<header>
<div class="item1">GRID ITEM 1</div>
<div class="item2">GRID ITEM 2</div>
<div class="item1">GRID ITEM 3</div>
<div class="item2">GRID ITEM 4</div>
</header>
</body>
CSS
header {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
}
div {
border: 1px solid;
}
I am having trouble setting 2 different column widths (1fr, 3fr)
only using auto-fit
and auto-fill
when in desktop screen mode. Is there any way to achieve this without using media queries? Or auto-fit
and auto-fill
are only used when columns are of the same width?