I have an input
element, inside a CSS grid container. The container should be 100 pixels wide, with the input
element taking up most of the space, and an other-thing
taking up the remaining 24px. I am using grid-template-columns
for this.
This works fine if I make the parent container 200px instead of 100px:
.container {
grid-template-columns: 1fr 24px;
grid-template-rows: 1fr;
display: grid;
justify-content: center;
align-items: center;
width: 200px; /* Try 100px */
background-color: red;
}
And the following HTML
<div class="container">
<input value="hello"/>
<div class="other-thing">
x
</div>
</div>
But if I make the container 100px wide, the input suddenly refuses to shrink - so it overlaps the red container.
I know
input
elements have a user stylesheet, but I can't see anything related to width or display there that I should be overriding.
How do I make the input
only use the remaining space in the container, preferably using grid-template-columns
?