直接po代码了:作者:Zonda
链接:https://www.zhihu.com/question/20618579/answer/25264369
来源:知乎
著作权归作者所有,转载请联系作者获得授权。
用一个div套住img
然后依次为div设置样式
.commentAvatarDiv{
width: 32px;
height: 32px;
padding:2px;
background: #ececec;
border-radius:32px;
box-shadow: 0px 0px 1px rgba(0,0,0,0.4);
-moz-border-radius: 32px;
-webkit-border-radius: 32px;
}
为img设置样式
.commentAvatarImage{
width:32px;
height:32px;
line-height: 0; /* remove line-height */
display: inline-block; /* circle wraps image */
border-radius: 50%; /* relative value */
-moz-border-radius: 50%;
-webkit-border-radius: 50%;
transition: linear 0.25s;
}
ps:实现效果很好!