I am creating a simple form, where I want to have this kind of layout
So far so good, very simple 2 columns with a nested 2 columns, all of them defined with 0.5fr which should be the half of "free-space" if I understood correctly.
But, if I try to reduce the screen, this happens. even if I have NO media queries.
if you debug with chrome devtools you can see it's creating a 3rd column from nowhere without any element. Any idea?
https://stackblitz.com/edit/js-zzm4gy?file=index.html
h1, h2 {
font-family: Lato;
}
.form{
border: 1px solid black;
text-align: center;
display: grid;
grid-template-rows: 1fr;
grid-gap: 1em;
}
.two-field{
display: grid;
grid-template-columns: 0.25fr 0.75fr;
}
/********************/
/* Four elements row*/
/********************/
.four-field{
display: grid;
grid-template-columns: 0.5fr 0.5fr;
}
.four-field .left{
display: grid;
grid-template-columns: 0.5fr 0.5fr;
}
.four-field .right{
display: grid;
grid-template-columns: 0.25fr 0.75fr;
}
/********************/
/********************/
/********************/
/********************/
/******Buttons*******/
/********************/
.buttons{
display: grid;
grid-template-columns: 0.25fr 0.75fr;
}
.button-column{
display: grid;
grid-template-columns: 0.5fr 0.5fr;
grid-column-gap: 1em;
}
/********************/
/********************/
/********************/
<div id="app">
<form class="form">
<div class="two-field">
<label>First name:</label>
<input type="text" name="firstname">
</div>
<div class="four-field">
<div class="left">
<label>Postal code:</label>
<input type="text" name="Postal code">
</div>
<div class="right">
<label>Place:</label>
<input type="text" name="Place" >
</div>
</div>
<div class="two-field">
<label>Phone</label>
<input type="text" name="phone">
</div>
<div class="buttons">
<div class="empty"></div>
<div class="button-column">
<button type="submit">Confirm</button>
<button>Abort</button>
</div>
</div>
</form>
</div>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…