X
X
XenTerSeO2015-10-17 20:37:25
css
XenTerSeO, 2015-10-17 20:37:25

How to set the same size of blocks with images if the images are of different sizes?

Here is an example - https://jsfiddle.net/9hhb9d7x/
Images change height and width when resolution is changed.
But one image is larger than the other, which needs to be fixed.
If you set the height of the parent block - https://jsfiddle.net/junt58e4/ , then the images will no longer stretch, as in the first option, and will only resize in width when the resolution changes.
How can I make image blocks stretch like in the first option, but have the same height as in the second one?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivanq, 2015-10-17
@XenTerSeO

https://jsfiddle.net/Ivanq/9hhb9d7x/3/

M
Magzhan Birgebayuly, 2015-10-17
@henhanshi

Use in style:

.box{
  background-image: url(...);
  background-size: auto 100%;
  border: 1px solid #eee;
  float: left;
  height: 200px;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question