Box Sizing
Try adding box-sizing: border-box;
to the input
styles.
The default box-sizing
(content-box
) doesnt take the padding into consideration when rendering size. By default, most browsers add padding to inputs in the base browser styles.
This means if you set the width of something to 100px but that something has a left padding of 5px, the total rendered width will be 105px!
This is why a LOT of CSS resets add * { box-sizing: border-box; }
to the reset because it is arguably more intuative.
You can read more about box-sizing if you're interested.
body {
display: grid;
place-items: center;
}
div {
border: 1px solid red;
}
input {
box-sizing: border-box;
max-width: 100%;
width: 260px;
}
<div>
<input type="text">
</div>