To illustrate the problem in Safari, let's begin with a plain image.
Here we have an image of 100px x 100px. Adding a border of 3px increases the element dimensions to 106px x 106px:
Now we give it a border radius of 20%:
You can see it starts cropping from the outer boundary of the element, not from the image itself.
Further increasing the magnitude to 50%:
And changing the border color to white:
You can now see how the issue arises.
Because of such behavior of the browser, when creating an image in a circle with a border, we have to make sure both the image and the border are given a border radius. One way to ensure this is to separate the border from the image by placing the image inside a container, and apply border radius to both of them.
<div class="activity_rounded"><img src="http://placehold.it/100" /></div>
.activity_rounded {
display: inline-block;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
-khtml-border-radius: 50%;
border: 3px solid #fff;
}
.activity_rounded img {
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
-khtml-border-radius: 50%;
vertical-align: middle;
}
And now we have a nice circle border around the image on Safari.
// img 태그에 border를 주는것이 아니라 img를 감싼 태그에 border 및 box-shadow를 줌.
데모 보기 : http://jsfiddle.net/3XSJN/1/
'# Work > └ html5&css3' 카테고리의 다른 글
css3 브라우저별 지원 현황 (0) | 2014.01.21 |
---|---|
css selector (선택자) 의 종류와 브라우저별 지원 여부 (0) | 2014.01.21 |
canvas 요소 2 (0) | 2013.11.13 |
canvas 요소 (0) | 2013.11.12 |
html5 속성들 (html5 오픈컨퍼런스 by 정찬명님 발표 동영상을 보고...) (0) | 2011.12.19 |