简体   繁体   English

使图像调整大小像背景图像

[英]Make images resize like a background image

I been looking everywhere, and I can recall I seen a solution to this before, but no luck in finding it back. 我到处都在寻找,我还记得我以前曾对此找到解决方案,但是找回它并不幸运。 Is it possible to make images without a div around it, or being used as background, nevertheless scale like those? 是否可以使图像周围没有div或用作背景,但仍可以像这样缩放?

Example: 例:

<div class="container">
    <img src="example-1.jpg" class="50-100">
    <img src="example-1.jpg" class="50-100">
    <img src="example-1.jpg" class="25-50">
    <img src="example-1.jpg" class="75-50">
</div>

How would I have to style the above images, to make them blocks of 50% width and 100% height(of width container, like one would do with padding-bottom for an image with backgound) for the first two and width: 25%, height 50% for the third and 75%/50% for the last? 我该如何对上面的图像进行样式设置,以使它们的前两个宽度为50%宽度和100%高的块(宽度容器,就像对带有背景的图像的底部填充区域一样):25% ,第三高50%,最后75%/ 50%? This in such way the images are blocks, with the image itself cropped to fill the size. 这样,图像成为块,图像本身被裁剪以填充尺寸。

Hope this makes sense... 希望这有道理...

İ'm not sure, but you could use: İ不确定,但您可以使用:

width: 50%;
height: 100%;

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

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