html - 带有 img 的圆形 div width<height height<width HTML/CSS

标签 html css image rounding

所以我有一个圆形的 div,里面有一个 img。问题是:

#mydiv
{
width: 50px;
height: 50px;
overflow: hidden;
border-radius: 25px;
}

现在,如果用户上传一张高度小于宽度的图片 我可以采用高度:50 像素和宽度:自动;

但是如果用户上传的图片宽度小于高度 我需要使高度:自动;宽度:50px;

如果错误,div 没有填充此 img。

我该如何解决?

对不起,我是德国学生,所以我写得不好:/

最佳答案

将图片放在css中:

背景:url(img/...) no-repeat center center; 背景大小:覆盖;

就是这样!

关于html - 带有 img 的圆形 div width<height height<width HTML/CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39906516/

相关文章:

javascript - 在 IE10 中,图像在鼠标移动时旋转

javascript - 如何让我的页面在不滚动的情况下按比例显示?

html - 使 div 内的 div 响应

html - 中心位置 : absolute and make it full size

javascript - 在浏览器中渲染文件

php - 具有多个参数的分页问题

javascript - 如何将自定义图像标签添加到 pagedown?

css3 变换图像的旋转

java - Javadoc 的图像文件放在哪里?

swift - 如何在swift中通过web api将图像保存到数据库表