简体   繁体   English

使所有图像大小相同

[英]Make all images to be of the same size

On my way on implemented my idea , I am trying to put a lot (toy example: 4) images in one slide of the carousel of Bootstrap. 在实现我的想法的过程中 ,我试图在Bootstrap轮播的一张幻灯片中放置很多(玩具示例:4张)图像。 However, I am failing big time on resizing them so that all the images have same characteristics in dimensions, regardless of their original ones. 但是,我没有花太多时间调整它们的大小,以使所有图像都具有相同的尺寸特征,而不管其原始尺寸如何。

Here is the jsFiddle where I display the issue in slide 1, and here is just one of the many attempts I made: 这是我在幻灯片1中显示问题的jsFiddle ,这只是我进行的许多尝试之一:

img.resize{
    width:256px;
    height: 256px;
}

You see, I would like the images to all have the same dimensions, for visualization purposes. 您看,我希望图像都具有相同的尺寸,以实现可视化目的。 How to do that? 怎么做?

In other words, what I want is every image to be of the same width x height dimensions. 换句话说,我想要的是每个图像都具有相同的width x height尺寸。 Like we were passing them through a neural layer that would trim the dimensions to make them homogenous, like all of them were placed on the same box! 就像我们将它们穿过神经层一样,该神经层会修剪尺寸以使其均匀,就像它们都放置在同一个盒子中一样! The ideal thing would be to get something like what t he search engines give you (where the height is the same for all, and the width might differ a bit, but wrt to visualization that doesn't cause any harm). 理想的做法是获得类似于他的搜索引擎给您的东西 (高度相同,宽度可能有所不同,但可视化不会造成任何危害)。

Now, the black is shorter than the yellow. 现在,黑色比黄色短。

use max-width and set the .item class's height... and overflow: hidden : 使用max-width并设置.item类的高度...并overflow: hidden

Fiddle 小提琴

4 images in 1 slide: Fiddle . 1张幻灯片中的4张图像: 小提琴 Be aware that with just straight images you won't be able to make them the same size. 请注意,仅使用平直的图像将无法使它们具有相同的尺寸。 Well, unless you want them squished and squeezed to look horrible. 好吧,除非您希望它们被挤压并挤压得看起来很恐怖。

If you want all 4 images to appear to be the same size, you need additional markup, such as a div wrapping the image tags. 如果要使所有4张图像看起来都相同,则需要其他标记,例如div包裹图像标签。 This is how things like Google images does it.... they wrap the image tag in a div, then hide any overflow of that div. 这就是Google图片的处理方式。...将图片标签包装在div中,然后隐藏该div的所有溢出内容。

You can't resize 4 images in that current markup to be exactly the same size in a single one of those slides. 您无法在其中一张幻灯片中将当前标记中的4张图像调整为完全相同的尺寸。 Images themselves can't be cropped or have portions hidden. 图片本身无法裁剪或隐藏部分。 It's surrounding elements that cause images to appear cropped by hiding any overflow. 周围的元素通过隐藏任何溢出导致图像显得被裁剪。

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

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