具有背景透明的圆形图像

问题描述 投票:-1回答:1

我尝试使用css裁剪后四舍五入并成像

    .rounded{
        border-radius: 100% !important;
        -moz-border-radius: 100% !important;
        -webkit-border-radius: 100% !important;
        display: inline-block;
     }

但是我需要透明的背景。也许我可以用画布做到这一点吗?我正在寻找示例,但我发现的只是正方形或矩形。我需要四舍五入。

css canvas html5-canvas
1个回答
0
投票

您必须设置固定的宽度和高度,然后添加对象对象属性以对其进行裁剪,边界半径的50%应该足够:

.rounded {
  border-radius:50%;
  object-fit:cover;
  height:200px;
  width:200px;
}

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.