转自:https://www.cnblogs.com/lhyhappy365/p/9306138.html
1、方法一
直接设置img为圆形,这种情况下如果图片不是正方形,图片会被拉伸
|
1
|
<img class="circleImg" src="../img/photo/img.jpg" /> |
相应的css为
|
1
2
3
4
5
|
.circleImg{ border-radius: 30px; width:60px; height:60px;} |
boder-radius为图片宽度的一半
通过背景图设置
|
1
|
<div class="bgImg"></div> |
相应的css为
.bgImg{
border-radius: 30px;
width:60px;
height:60px;
background: url("../img/photo/img.jpg") no-repeat center;
background-size:60px;
}
拖图片不是方形,则按照宽度等比例显示,则background-size设置为图片宽度,高度为auto,若需要按照高度等比例显示,则background-size:auto 60px;

更多精彩内容:各种AI课程、技能课程、黑科技软件、网站小程序源码、副业小项目、PPT模板等精品素材、电商课程、推广引流课程等,尽在 天边资源网 。
Google Chrome
Windows 10