Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS Border Radius not working on iOS

Tags:

css

ios

safari

I'm having some trouble with borders on iOS (safari).

I have an image (my gravatar) which I want to give a round border which is 10px solid and white.

To achieve this I have the HTML

<img src="http://2.gravatar.com/avatar/b7c2d49748426791dc98b8214dfac9d1?s=500" class="img-circle" height="300" width="300">

and the CSS

.img-circle {
-webkit-border-radius: 500px;
-moz-border-radius: 500px;
border-radius: 500px;
border: solid 10px white;
}

JSFiddle http://jsfiddle.net/2UT8v/2/

I'm using twitter's bootstrap and so the border-radius is being specified by their class .img-circle (that is why the radius is 500px) and then I've added the border weight and color.

This works well on a desktop browser (Chrome) but when viewing on iOS (safari on my iPad) it shows the 10px solid white border is still a square around the original image and the radius is applied after and so cuts off some of the border.

Border In ChromeBorder In iOS

Does anybody know how I can get the border to follow the radius in iOS?

like image 413
Jacob Tomlinson Avatar asked Mar 10 '13 19:03

Jacob Tomlinson


People also ask

How do you put a radius on a border in CSS?

CSS Syntaxborder-radius: 1-4 length|% / 1-4 length|%|initial|inherit; Note: The four values for each radius are given in the order top-left, top-right, bottom-right, bottom-left. If bottom-left is omitted it is the same as top-right. If bottom-right is omitted it is the same as top-left.

What is WebKit border radius?

The border-radius property in WebKit accepts one or two values and uses them to style all four corners making a nice symmetric shape. The new Firefox syntax allows you to define four different round or elliptical corners. A slash has been introduced to separate the horizontal and vertical length settings.

Can CSS outline have a radius?

The outline-radius property is used to specify the radius of an outline. It is used to give rounded corners to outlines. This property can only be used in Firefox2-87 (till march 2021) and from Firefox 88, outline-property follows the shape created by border-radius automatically, so this property is no longer needed.

How do you set border radius in react native?

Border Radius in React NativeThe borderRadius property can be set as the style attribute to any element. It takes a value in pixels and assigns that value to the overall border radius of that UI element. By default, the border radius of any element is 0 if you haven't added that style attribute to that element.


1 Answers

Quick and dirty solution: http://jsfiddle.net/mEZEj/ Use box-shadow instead of border.

Clean solution: http://jsfiddle.net/TjUum/ Use a block div element with the avatar as the background-image. Adjust as needed.

like image 165
Jen Avatar answered Oct 04 '22 04:10

Jen