I have a few questions about the CSS grid styling in my CodeSandbox here because it's not behaving how I would expect: https://codesandbox.io/s/rw0j2orqmp
- Why is the spacing between C, CE, backspace and the numbers smaller than the spacing between the numbers and +-, 0, . ?
- Why do I need to set my padding to 0 on the textarea element? If I don't, the sides extend out to the right farther than to the left.
- If my setting of #backspace to position: absolute; is taken away, why does the backspace shift up one pixel?
- Why do I have to use flex box to make the clear grid area appear correctly without wrapping backspace to the bottom? This is not necessary on the bottom row.
- Why does my method > * {} call not put the margins in for all the children? Should it not space them apart? Is there a better way to auto-space the children of method on the right side?
Below is my scss script:
.calculator {
margin: auto;
vertical-align: center;
width: 215px;
height: 330px;
background-color: blue;
display: grid;
grid-template-rows: repeat(2, auto);
grid-template-columns: auto;
grid-template-areas:
"display"
"buttons";
#display {
grid-area: display;
margin: 5px;
padding: 0;
resize: none;
text-align: right;
font-size: 40px;
width: 95%;
height: 100px;
}
.buttons {
grid-area: buttons;
display: grid;
margin: 0px 5px 5px 5px;
padding: 0;
grid-template-rows: repeat(5, auto);
grid-template-columns: repeat(4, auto);
grid-template-areas:
"clear clear clear method"
"number number number method"
"number number number method"
"number number number method"
"bottom bottom bottom method";
.clear {
grid-area: clear;
#backspace {
position: absolute;
}
}
.method {
display: flex;
flex-direction: column;
grid-area: method;
.method > * {
margin-top: 1px;
}
}
.number {
grid-area: number;
}
.bottom {
grid-area: bottom;
}
}
}
button {
width: 50px;
height: 40px;
padding: 0;
}
I think I may have a misunderstanding of how some of these pieces work, so any advice, tips, corrections, or workarounds you can provide would be greatly appreciated.