I was wondering how does the Css grid layouts.
I am trying to figure out a grid layout which make all input in a row and fit the grid column.
.grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
grid-gap: 4px;
}
<div class="grid">
<div class="one">
<label for="aaa">aaa</label>
<input type="text" name="cheese" />
</div>
<div class="two">
<label for="bbb">bbb</label>
<input type="text" name="cheese" />
<span>~</span>
<input type="text" name="cheese" />
</div>
<div class="three">
<label for="ccc">ccc</label>
<input type="text" name="cheese" />
</div>
</div>
Below is what I need. Thanks.
2
Answers
I used a combination of
CSS Grid
andFlexbox
to achieve the desired layout. I believe this approach aligns with what you’re looking for, but if it doesn’t fully meet your needs, you may need to make a few minor adjustments.You can do this with a grid, ensuring the children of the divs take part in the grid by using display: contents on their parents.