<p>У цьому прикладі, Ви можете змінювати значення для властивості <strong>grid-gap</strong>:</p>
<p>У цьому прикладі для властивості задаються значення у пікселях (px) у формі: "grid-row-gap grid-column-gap". Одне значення застосовується для двох властивостей відразу.</p>
<input type="number" id="row" class="input" min="0" value="16">px
<input type="number" id="column" class="input" min="0" value="32">px
<div class="box">
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
<div class="item">4</div>
<div class="item">5</div>
<div class="item">6</div>
<div class="item">7</div>
<div class="item">8</div>
<div class="item">9</div>
</div>
body {
font-family: monospace;
font-size: 16px;
line-height: 1.45;
}
.input {
margin-bottom: 36px;
padding: 4px;
font-size: 18px;
}
.box {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-row-gap: 16px;
grid-column-gap: 32px;
}
.box .item {
background-color: tomato;
color: white;
font-size: 1.4em;
font-family: monospace;
padding: 16px;
text-align: center;
}
$('.input').on('change', function() {
$('.box').css('grid-gap', $('#row').val() + 'px ' + $('#column').val() + 'px');
});
This Pen doesn't use any external CSS resources.