Reputation: 5293
In my website i want to show profile pictures are in a circle shape ina particular area. In my folder it is in rectangular page. For that i am using following styles but not not working
<div class="circle">
<img src="~/Content/Member/MemberPhotos/default_user_icon.jpg"/></div>
</div>
tried to mask with a shape image
.circle {
width:100px;height:100px;
overflow: hidden;
-webkit-mask-image: url(crop.png);
}
and also tried the following css
.circle {
width:100px;
height:100px;
border-radius: 50px;
background-color:#000;
clip: rect(0px,50px,100px,0px);
}
both are not masked. anybody please help me
Upvotes: 0
Views: 416
Reputation: 3165
Border radius would be the best solution. If you want to support IE8 then you will have a problem because it doesn't support border-radius. So your solution with mask would be more appropiate. Or maybe sometime in the future you will want to use a mask with another effect, other than circle. So here is a solution:
.circle{
width:100px;
height:100px;
position:relative;
}
.circle:after{
content:"";
width:100px;
height:100px;
left:0px;
top:0px;
background-image:url(crop.png);
z-index:5;
}
Upvotes: 1
Reputation: 2535
<div class="circle">
<img src="~/Content/Member/MemberPhotos/default_user_icon.jpg" style="border-radius: 50% 50% 50% 50%" />
</div>
That should do it.
Upvotes: 3