简体   繁体   English

如何用 css 和 html 的图像填充圆圈?

[英]How to fill a circle with an image with css and html?

For some reason, my image is not filling out the entire circle.出于某种原因,我的图像没有填满整个圆圈。 It's only a smaller version of the image that is showing in my circle.这只是我圈子中显示的图像的较小版本。 I need the image to fill out the entire circle.我需要图像来填充整个圆圈。 How can I do that?我怎样才能做到这一点?

<figure [ngStyle]="{ 'box-shadow': '0px 5px 5px 0px red'  }">
  <img [src]="'https://img2.androidappsapk.co/115/b/1/a/com.ludicside.mrsquare.png'" alt="resource.Name">
</figure>

My css我的 css

 figure { float: left; background: #f3f3f3; border-radius: 20px; font-size: 50px; text-align: center; margin-right: 10px; border-radius: 50%; /* display:inline-block; */ padding: 10px; height: 66px; width: 66px; box-shadow: 0px 5px 5px 0px blue; } figure img { display: block; height: auto; max-width: 100%; max-height: 100%; object-fit: cover; } * { -webkit-box-sizing: border-box; box-sizing: border-box; }
 <figure> <img src="https://img2.androidappsapk.co/115/b/1/a/com.ludicside.mrsquare.png" alt="resource.Name"> </figure>

Try this way by giving width: 100%;通过给出width: 100%; and overflow: hidden;overflow: hidden; to the parent.给父母。

 figure { background: #f3f3f3; border-radius: 50%; height: 66px; width: 66px; box-shadow: 0px 5px 5px 0px blue; overflow: hidden; } figure img { height: auto; width: 100%; } * { -webkit-box-sizing: border-box; box-sizing: border-box; }
 <figure> <img src="https://img2.androidappsapk.co/115/b/1/a/com.ludicside.mrsquare.png" alt="resource.Name"> </figure>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM