<pre class="code-container">
<code>
<span class="token-selector">.item:nth-child(3)</span> {
<span class="token-property">grid-column-start</span>: <input type="text" data-property="grid-column-start" class="token-function" />
<span class="token-property">grid-column-end</span>: <input type="text" data-property="grid-column-end" class="token-function" />
<span class="token-property">grid-row-start</span>: <input type="text" data-property="grid-row-start" class="token-function" />
<span class="token-property">grid-row-end</span>: <input type="text" data-property="grid-row-end" class="token-function" />
}
</code>
</pre>
<div class="grid">
<div>1</div>
<div>2</div>
<div class="item">3</div>
<div>4</div>
<div>5</div>
<div>6</div>
<div>7</div>
<div>8</div>
<div>9</div>
<div>10</div>
<div>11</div>
<div>12</div>
<div>13</div>
<div>14</div>
<div>15</div>
<div>16</div>
</div>
* {
box-sizing: border-box;
}
body {
display: flex;
flex-wrap: wrap;
align-items: flex-start;
justify-content: center;
padding: 1rem;
gap: 2rem;
margin: 0;
min-height: 100vh;
background: linear-gradient(45deg, #d8c79c 10%, #e2d1a6 0, #e2d1a6 90%, #d8c79c 0, #d8c79c 100%);
}
.grid {
display: grid;
grid-template-columns: repeat(4, 100px);
grid-template-rows: repeat(4, 100px);
grid-auto-rows: 100px;
gap: 0.5rem;
}
.grid div {
display: flex;
justify-content: center;
align-items: center;
border-radius: 15px;
font-size: 22px;
background-color: #151321;
color: #febc14;
}
.item {
--grid-column-start: 1;
--grid-column-end: -1;
--grid-row-start: 2;
--grid-row-end: 4;
grid-column-start: var(--grid-column-start);
grid-column-end: var(--grid-column-end);
grid-row-start: var(--grid-row-start);
grid-row-end: var(--grid-row-end);
}
output {
display: block;
}
.code-container {
max-width: 100%;
overflow-x: auto;
background-color: #272822;
margin: 0;
padding: 0 24px;
border-radius: 3px;
color: #F8F8F2;
text-shadow: 0 1px rgba(0, 0, 0, 0.3);
font-family: Consolas, Monaco, 'Andale Mono', monospace;
font-size: 16px;
line-height: 1.7;
}
.token-property {
color: #F92672;
}
.token-selector {
color: #a6e22e;
}
.token-function {
color: #E6DB74;
display: inline-block;
}
input[type="text"] {
border: 0;
background: none;
width: 70px;
font: inherit;
}
input[type="text"]:focus {
border: 1px solid currentColor;
}
var item = document.querySelector('.item');
var inputs = document.querySelectorAll('input[type="text"]');
for (var i = 0; i < inputs.length; i++) {
inputs[i].value = getComputedStyle(item).getPropertyValue('--'+inputs[i].getAttribute('data-property'));
inputs[i].addEventListener('input', function () {
item.style.setProperty('--'+this.getAttribute('data-property'), this.value);
document.querySelector('.'+this.getAttribute('data-property')).querySelector('span').textContent = this.value;
}, false);
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.