您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

CSS强制调整图像大小并保持宽高比

CSS强制调整图像大小并保持宽高比

img {

  display: block;

  max-width:230px;

  max-height:95px;

  width: auto;

  height: auto;

}


<p>This image is originally 400x400 pixels, but should get resized by the CSS:</p>

<img width="400" height="400" src="http://i.stack.imgur.com/aEEkn.png">

如果对于指定区域太大,则会缩小图像(不利的一面是,不会放大图像)。

CSS 2022/1/1 18:17:21 有547人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶