Turn off iPhone/Safari input element rounding

前端 未结 11 1186
时光取名叫无心
时光取名叫无心 2020-11-28 17:06

My website renders well on the iPhone/Safari browser, with one exception: My text input fields have a weird rounded style which doesn\'t look good at all with the rest of my

相关标签:
11条回答
  • 2020-11-28 17:45

    The accepted answer made radio button disappear on Chrome. This works:

    input:not([type="radio"]):not([type="checkbox"]) {
        -webkit-appearance: none;
        border-radius: 0;
    }
    
    0 讨论(0)
  • 2020-11-28 17:49

    In order to render the buttons properly on Safari and other browsers, you'll need to give a specific style for the buttons in addition to setting webkit-appearance to none, e.g.:

    border-radius: 0;
    -webkit-appearance: none;
    background-image: linear-gradient(to bottom, #e4e4e4, #f7f7f7);
    border: 1px solid #afafaf
    
    0 讨论(0)
  • 2020-11-28 17:50

    I used a simple border-radius: 0; to remove the rounded corners for the text input types.

    0 讨论(0)
  • 2020-11-28 17:51

    Here is the complete solution for Compass (SCSS):

    input {
      -webkit-appearance: none;  // remove shadow in iOS
      @include border-radius(0);  // remove border-radius in iOS
    }
    
    0 讨论(0)
  • 2020-11-28 17:52

    If you use normalize.css, that stylesheet will do something like input[type="search"] { -webkit-appearance: textfield; }.

    This has a higher specificity than a single class selector like .foo, so be aware that you then can't do just .my-field { -webkit-appearance: none; }. If you have no better way to achieve the right specificity, this will help:

    .my-field { -webkit-appearance: none !important; }

    0 讨论(0)
  • 2020-11-28 17:54

    For me on iOS 5.1.1 on a iPhone 3GS I had to clear the styling of a search field and the set it to the style intended

    input[type="search"] {-webkit-appearance: none; border-radius: 0 3px 3px 0;}
    

    Doing -webkit-border-radius: 0; alone did not clear the native styling. This was also for a webview on a native app.

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