一、CSS实现图片圆角的基础语法

img {
  border-radius: 10px; /* 四个角都设置相同的圆角半径 */
}

或者,可以分别设置每个角的圆角半径:

img {
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
  border-bottom-right-radius: 10px;
  border-bottom-left-radius: 10px;
}

二、图片圆角的具体实现方法

1. 使用border-radius属性

<img src="path/to/image.jpg" alt="圆角图片" style="border-radius: 20px;">

2. 使用background-image属性

<div style="position: relative; width: 100px; height: 100px; overflow: hidden;">
  <img src="path/to/image.jpg" alt="圆角图片" style="width: 100%; height: 100%; position: absolute; top: 0; left: 0;">
  <div style="position: absolute; top: 0; left: 0; right: 0; bottom: 0; border-radius: 20px; background-color: white;"></div>
</div>

3. 使用object-fit属性

<img src="path/to/image.jpg" alt="圆角图片" style="border-radius: 20px; object-fit: cover;">

三、设置技巧与细节

    兼容性border-radius属性在大多数现代浏览器中都得到了支持,但对于一些老旧浏览器,可能需要使用一些回退方案,如使用-webkit--moz-等前缀。