ChatGPT解决这个技术问题 Extra ChatGPT

Stop Safari Mobile from giving input buttons rounded corners

I guess the subject says it all. I have a web application when viewed on an Iphone, Ipod or Ipad, input submit buttons have rounded corners. Is there a way to stop this?


m
methodofaction

If you add...

input, textarea {
  -webkit-appearance: none;
  border-radius: 0;
}

Then your buttons will inherit any CSS styles that you have applied for other browsers.


This doesn't work on iPad2, iOS 5.1.1. I can't be certain that it won't work on other iOAS devices, though, since I haven't got any to test it with. However, Roel's -webkit-border-radius:0px solution does work.
If you don't apply -webkit-appearance: none then Safari gets picky on the properties that can be applied on it (namely, font-size and color. The best solution would be applying both.
Reporting in to confirm that this solution works for iPad, iOS 5.1.1.
replying to a 2-year old comment.... oh well. -webkit-appearance: none; causes checkboxes to not be visible in Chrome. Probably affects other elements and browsers as well.
WOW!!! We were searching for hours to fix this in a cordova app and this was the solution! I can't upvote this enough!!!
R
Roel

Didn't work for me, the -webkit-appearance:none.

This does:

input[type=submit] {
    -webkit-border-radius:0px;
}

I had the same issue with rounded corners on a button with background image, just on the iPhone.


Confirming: the highest voted answer here (by Duopixel) doesn't work, but Roel's answer does. This is probably due to a change made to Apple's mobile webkit implementation in the intervening months.
@CoreDumpError - You mean it doesn't work for you. The solution worked for me - I've just implemented it. Not sure why we're experiencing different outcomes. Then again, your post was made over half a year ago so I can't tell if you're still experiencing the same issue.
@Roel, you may simply have precedence issues... ?
K
Kishan_KP

You can try to use following CSS:

-webkit-appearance:none;

More info: http://trentwalton.com/2010/07/14/css-webkit-appearance/


S
Stephan Branczyk

I've found that on iPad 2 you have to use the following:

-webkit-appearance:none;
border-radius: 0;

in your button class.


R
RevConcept

I had a site with an input submit type="image". This vairation of the above fixed the rounded corners:

input[type=image] {
    -webkit-border-radius:0px;
}

m
mait

I've found that setting background: linear-gradient(color1, color2) gets rid of the overly rounded corners on Apple devices and works on all other browsers/platforms I have tried.


This fixed it for me and it seems to me to be the least likely option to have unintended side-effects.
A
AGalvis

I solved by adding code for both the "button" and "submit" types:

   input[type="submit"] {
   text-align: center;
        -webkit-appearance:none;
        -webkit-border-radius:0px;
        border-radius:0;
        height:30px;
    }

    input[type="button"] {
        text-align: center;
        -webkit-appearance:none;
        -webkit-border-radius:0px;
        border-radius:0;
        height:30px;
    }