问题
Why does an input form on mobile Safari have more padding inside it and push the text to the right so it gets cut off?
I set the width of the input field at 20px which is plenty for the desktop web but on mobile it needs >26px.
^ Desktop Safari Web Input Form ^
^ Mobile iOS Safari Input Form ^
CSS
.phone-input {
width: 20px;
text-align: center;
font-size: 16px !important;
height: 1.75em;
//border: 0;
outline: 0;
background: transparent;
}
HTML
'<div class="phone-field">'+
'(<input class="phone-input" name="phone-input" type="tel" size="1" maxlength="1" placeholder="-" autofocus="autofocus"><input class="phone-input" name="phone-input" type="tel" size="1" maxlength="1" placeholder="-"><input class="phone-input" name="phone-input" type="tel" size="1" maxlength="1" placeholder="-">) '+
'<input class="phone-input" name="phone-input" type="tel" size="1" maxlength="1" placeholder="-"><input class="phone-input" name="phone-input" type="tel" size="1" maxlength="1" placeholder="-"><input class="phone-input" name="phone-input" type="tel" size="1" maxlength="1" placeholder="-"> - '+
'<input class="phone-input" name="phone-input" type="tel" size="1" maxlength="1" placeholder="-"><input class="phone-input" name="phone-input" type="tel" size="1" maxlength="1" placeholder="-"><input class="phone-input" name="phone-input" type="tel" size="1" maxlength="1" placeholder="-"><input class="phone-input" name="phone-input" type="tel" size="1" maxlength="1" placeholder="-">'+
'<\/div>'
回答1:
It took me hours to figure out, but the solution is simple:
Just use padding: 0;
(Mobile safari adds a default padding to input fields)
来源:https://stackoverflow.com/questions/31860787/why-does-mobile-safari-cut-off-the-text-in-an-input-form