0

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

1
  • 1
    Add overflow:hidden to .circle (the second one). Commented Aug 29, 2013 at 10:08

2 Answers 2

3
<div class="circle">
 <img src="~/Content/Member/MemberPhotos/default_user_icon.jpg" style="border-radius: 50% 50% 50% 50%" />
</div>

That should do it.

Sign up to request clarification or add additional context in comments.

Comments

1

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;
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.