【问题标题】:show image in aspect ratio and all image size same height and width以纵横比显示图像,所有图像大小相同的高度和宽度
【发布时间】:2014-11-08 20:32:56
【问题描述】:

我在 PHP/MySQL 数据库中创建了一个图片库。如何以相同的图像大小以纵横比显示图像?

这是我的css代码:

img
{
  display: block;
  max-width: 100%;
  max-height: 100%;
  margin: auto;
  -webkit-transition: all 2s ease-out;
  transition: all 2s ease-out;

  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
}

在此代码中,图像的比例是正确的,但它显示的图像大小不同。我想在以下位置显示整个图像:

width:150px;
height:200px;

我该怎么做?

【问题讨论】:

  • 所有图像的纵横比是否相同或不同?

标签: php html mysql css image


【解决方案1】:

你可以使用这个:http://getbootstrap.com/css/#images

以及具有所需宽度和高度的父元素。

【讨论】:

    猜你喜欢
    • 2011-12-27
    • 2021-02-09
    • 2015-05-22
    • 1970-01-01
    • 1970-01-01
    • 2011-06-12
    • 2011-12-24
    • 2014-02-06
    • 2013-04-05
    相关资源
    最近更新 更多