0

在我的网站中,我想显示个人资料图片在特定区域呈圆形。在我的文件夹中,它位于矩形页面中。为此,我使用以下样式但不起作用

<div class="circle">
     <img src="~/Content/Member/MemberPhotos/default_user_icon.jpg"/></div> 
</div>

试图用形状图像掩盖

 .circle {
width:100px;height:100px;
overflow: hidden;
-webkit-mask-image: url(crop.png);
}

并且还尝试了以下CSS

.circle {  
width:100px;  
height:100px;  
border-radius: 50px;
background-color:#000; 
clip: rect(0px,50px,100px,0px); 
}

两者都没有被掩盖。任何人请帮助我

4

2 回答 2

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

那应该这样做。

于 2013-08-29T10:13:33.230 回答
1

边界半径将是最好的解决方案。如果您想支持 IE8,那么您将遇到问题,因为它不支持边框半径。所以你的面具解决方案会更合适。或者,也许在将来的某个时候,您会想要使用具有其他效果的蒙版,而不是圆形。所以这里有一个解决方案:

.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;
}
于 2013-08-29T10:31:37.090 回答