Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't border-radius work properly on text inputs in MobileSafari?

Here is a reference HTML document:

<!DOCTYPE html>
<html>
    <head>
    <style>
body { background-color: #000; }
input { -webkit-border-radius: 20px; }
    </style>
    </head>
    <body>
        <input type="text" value="text" />
    </body>
</html>

The border-radius renders fine on Safari/WebKit-based desktop browsers, but on the "MobileSafari" variant, namely the iPhone and iPad browsers, it renders with this strange box, which destroys the illusion of rounded corners when the input is being displayed on top of a differently-colored background.

like image 670
Abraham Vegh Avatar asked Jun 10 '10 17:06

Abraham Vegh


2 Answers

I managed to fix this by reducing the border radius.

The bug seems to only present itself if the border radius is greater than half the height of the element.

So if -webkit-border-radius: 20px; make sure your element is at least 40 pixels tall.

Otherwise the border backgrounds overlap causing the dreaded uglybox.

like image 61
KevBurnsJr Avatar answered Oct 05 '22 07:10

KevBurnsJr


Consensus from around the web is that this is a bug in WebKit for iOS. Don't use border-radius on text inputs on the iPhone.

like image 34
Abraham Vegh Avatar answered Oct 05 '22 09:10

Abraham Vegh