<input type=“submit”> padding bug on Safari mobile?

前端 未结 5 2079
眼角桃花
眼角桃花 2021-02-13 23:47

(This is similar to the (also unanswered) question #3430506, but applies to input tags instead of HTML5 elements.)

On buttons, th

相关标签:
5条回答
  • 2021-02-13 23:53

    I ran into this bug today when my mom told me that a page I had made was missing text on her old iPhone 3G. Sure enough, I fired up my wife's old 3G we have lying in a drawer someplace, and the text on one of my buttons is being pushed off to the side because Safari is inserting some giant spacing.

    The good news is that in the latest update (don't know exactly what, but I've got an updated iPhone 4), this bug has been fixed.

    Bad news is that if users don't update their browsers, I can't find any way around it outside of just not using the tag.

    My advice for right now is to check the version of Mobile Safari. If they're running the latest version (or whichever version fixed this bug or higher), they get the page with the button. If not, they can get served a page with alternate tags used to make the buttons. On my page this doesn't look as nice, and it's a little awkward, but I'm already checking browsers based on mobile or desktop versions of the site, so this isn't too much on top of that.

    Hope this helps.

    0 讨论(0)
  • 2021-02-14 00:13

    I had a similar issue and I noticed that my issue was resolved when I set the background to a gradient instead of just plain background-color.

    This somehow just ignored the padding values

    #submit{
        background:#a0b9dc;
        padding:9px 35px;
     }
    

    The code below resolved the padding issue for me on submit buttons.

    #submit{
        background:#a0b9dc;
        background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #A0B9DC));
        background: -o-linear-gradient(bottom, #A0B9DC 0%);
        background: -moz-linear-gradient(bottom, #A0B9DC 0%);
        background: -webkit-linear-gradient(bottom, #A0B9DC 0%);
        background: -ms-linear-gradient(bottom, #A0B9DC 0%);
        background: linear-gradient(to bottom, #A0B9DC 0%);
        padding:9px 35px;
    }
    
    0 讨论(0)
  • 2021-02-14 00:15

    Do you have control over the form? aka: did you manually enter the form?

    If so add either a id or class tag to it

    <input type="submit" id="submit" value="submit">
    

    then adjust your css to

    form input #submit { /* more specific to override webkit */ 
       -webkit-appearance:none;  
       -webkit-border-radius:0px;
       margin:0;  
       padding:0;  
       border:0;  
       display:block;
    }
    
    0 讨论(0)
  • 2021-02-14 00:15

    This might be a daft suggestion, but if the problem is with

    <input type="submit" /> 
    

    could you try changing it for

    <button type="submit" />
    

    Which does the same thing but might not have the bug?

    0 讨论(0)
  • 2021-02-14 00:20

    If you try setting the padding to an enormous value, say 100px, you'll notice that the top and bottom padding grow, while again left and right stays at the default value, in mobile Safari. So I suppose it's safe to assume that this quite simple counts as a bug in the webkit routines of iOS, and there is no direct solution unless Apple fixes the problem.

    A workaround would be to create a DIV that looks like whatever you want it to, and add an onclick handler that submits your form. No need to ever use a real submit button.

    0 讨论(0)
提交回复
热议问题