问题描述
我想将图像放置在圆圈图标width:64px;height:64px
中
但是我无法做到这一点。
我正在尝试的是这里:
https://jsfiddle.net/soniya_jain/esu413wv/5/
<html>
<img src="https://www.iphonehacks.com/wp-content/uploads/2019/06/Apple-ios-13-home-screen-iphone-xs-06032019.jpg" class="rounded imgProfile" height="55px" width="55px" alt="avatar">
</html>
<style>
.imgProfile {
display: block;
object-fit: contain;
}
</style>
任何想法或建议都会受到欢迎。
解决方法
您必须将其包装到容器中。
.image-container {
border-radius: 50%;
overflow: hidden;
height: 64px;
width: 64px;
}
.image-container img {
display: block;
height: 100%;
width: 100%;
object-fit: cover;
}
<html>
<div class="image-container">
<img src="https://www.iphonehacks.com/wp-content/uploads/2019/06/Apple-ios-13-home-screen-iphone-xs-06032019.jpg" alt="avatar">
</div>
</html>