I'm trying to create a simple numeric selector that will be used for mobile and desktop users. My idea is to have an input surrounded by "plus" and "minus" buttons.
Everything works fine except the responsiveness of the input field. Somehow, it doesn't shrink to the container remaining size.
So, what I would like to have is fixed-size spans (2 rem
in my case) around the input that takes all the remaining width of the container.
Here is the code:
body {
background: #f5f5f5;
}
.outer-container {
width: 300px;
border: 1px solid gray;
padding: 10px;
}
.container {
display: inline-flex;
align-items: center;
}
.item {
dsipaly: inline-block;
height: 2rem;
width: 2rem;
font-size: 2rem;
line-height: 2rem;
border: 1px solid black;
border-radius: 50%;
text-align: center;
}
input {
font-size: 2rem;
margin: 0 10px;
}
<div class="outer-container">
<div class="container">
<span class="left item">-</span>
<input type="text" />
<span class="right item">+</span>
</div>
</div>
I've created a layout that uses flexbox
but input doesn't shrink and overflows the container.
Is it possible to make an input to shrink to take all available container width without overflowing container on X axis?