I'm trying to create a tool to change margin/padding, that would look something like this
And I was able to get this far
I'm failing completely on showing the full inputs, overflow is not really working so I'm kind of lost now.
I did 2 boxes with each side has a label + input combination, to make the shape, I've used clip-path with poligon() function on the label, everything is pretty much aligned manually with position: absolute, and the input looks something like this:
input {
height: 1.5rem;
width: 3rem;
border: 1px solid #c0c0c0;
border-radius: 0.125rem;
text-align: center;
/* it's not working work */
overflow: visible;
}
Does anyone know what am I missing?
:root {
font-size: 16px;
}
.wrapper {
--initial-height: 10rem;
--initial-width: 24rem;
--deviation: 2px;
--thickness: 1rem;
position: relative;
margin: 2rem;
}
.box.outer {
--height: var(--initial-height);
--width: var(--initial-width);
height: var(--height);
width: var(--width);
position: absolute;
top: 0;
left: 0;
}
.box-border {
--padding: 0.125rem;
--height: calc(var(--initial-height) - 2 * var(--thickness) - 3 * var(--padding));
--width: calc(var(--initial-width) - 2 * var(--thickness) - 3 * var(--padding));
height: var(--height);
width: var(--width);
position: absolute;
top: calc(var(--thickness) + var(--padding));
left: calc(var(--thickness) + var(--padding));
border: 1px solid #808080;
}
.box.inner {
--height: calc(var(--initial-height) - 2 * var(--thickness) - 5 * var(--padding));
--width: calc(var(--initial-width) - 2 * var(--thickness) - 5 * var(--padding));
height: var(--height);
width: var(--width);
position: absolute;
top: var(--padding);
left: var(--padding);
}
.box h3 {
position: absolute;
top: 0.125rem;
left: calc(var(--thickness) * 1.2);
font-size: calc(var(--thickness) / 1.5);
z-index: 10;
margin: 0;
padding: 0;
line-height: 1;
font-family: Helvetica;
font-weight: 400;
}
.side {
background-color: #facc99;
}
label {
margin: 0;
padding: 0;
}
input {
height: 1.5rem;
width: 3rem;
border: 1px solid #c0c0c0;
border-radius: 0.125rem;
text-align: center;
/* @TODO fix - doesn't work */
overflow: visible;
}
.side {
position: absolute;
display: flex;
justify-content: center;
align-items: center;
}
.side.left {
top: 0;
left: 0;
width: var(--thickness);
height: var(--height);
clip-path: polygon( 0 var(--deviation), 100% calc(var(--thickness) + var(--deviation)), 100% calc(100% - var(--thickness) - var(--deviation)), 0 calc(100% - var(--deviation)));
}
.side.right {
top: 0;
right: 0;
width: var(--thickness);
height: var(--height);
clip-path: polygon( 100% var(--deviation), 100% calc(100% - var(--deviation)), 0 calc(100% - var(--thickness) - var(--deviation)), 0 calc(var(--thickness) + var(--deviation)));
}
.side.top {
top: 0;
left: 0;
width: var(--width);
height: var(--thickness);
clip-path: polygon( var(--deviation) 0, calc(100% - var(--deviation)) 0, calc(100% - var(--thickness) - var(--deviation)) 100%, calc(var(--thickness) + var(--deviation)) 100%);
}
.side.bottom {
bottom: 0;
left: 0;
width: var(--width);
height: var(--thickness);
clip-path: polygon( var(--deviation) 100%, calc(100% - var(--deviation)) 100%, calc(100% - var(--thickness) - var(--deviation)) 0, calc(var(--thickness) + var(--deviation)) 0);
}
<div class="wrapper">
<div class="box outer">
<h3>Margin</h3>
<label class="side top">
<input type="text" aria-label="margin top" />
</label>
<label class="side left">
<input type="text" aria-label="margin left" />
</label>
<label class="side right">
<input type="text" aria-label="margin right" />
</label>
<label class="side bottom">
<input type="text" aria-label="margin bottom" />
</label>
</div>
<div class="box-border">
<div class="box inner">
<h3>Padding</h3>
<label class="side top">
<input type="text" aria-label="padding top" />
</label>
<label class="side left">
<input type="text" aria-label="padding left" />
</label>
<label class="side right">
<input type="text" aria-label="padding right" />
</label>
<label class="side bottom">
<input type="text" aria-label="padding bottom" />
</label>
</div>
</div>
</div>

