So basically I have this
#calculator {
background-color: #212121;
border-radius: 10px;
overflow: hidden;
display: inline-block;
}
#functionality {
width: 100%;
height: 100%;
margin: 15px 5px 5px 15px;
overflow: hidden;
}
#display_calc {
max-width: 91%;
width: 91%;
height: 70px;
background-color: #1a1a1a;
}
#display {
min-width: 100%;
max-width: 100%;
height: 100%;
font-size: 50px;
background-color: rgba(0, 50, 0, 5);
color: white;
border: none;
}
<div id="calculator">
<div id="functionality">
<div id="display_calc">
<input id="display">
</div>
</div>
</div>
When I change the font size from display, the width gets very wide. I tried many things but nothing helps.
I tried putting many restrictions to the divs but the max width of the input does not work.
3
Answers
As far as I understood your question, I think you are using min-width and max-width for #display. That is something wrong I see. Simply use width : 100%. Also include box-sizing property as a good practice.
Try this and let me know if it helps. Thanks
If you’re trying to fit the input to screen width, removing
display: inline-block;
from#calculator
worked fine.But If you wanna keep display inline you can add
width: 100%;
to#calculator
The combination of inline-block and percentage width is what create the issue. You need to define a width (or max-width on the inline-block element)