S
S
Sarkis Arutiunian2015-09-23 07:38:51
css
Sarkis Arutiunian, 2015-09-23 07:38:51

How to dynamically change the height of an empty block?

I ran into a small problem, according to the draft link: usagid.com/pages/hotel/hotel_result.html
In the block with the establishment, when the width of the browser window changes, only the width of the block with the picture changes (the picture is set as a background, the block itself is empty).
I tried everything I knew, even the clientWidth property in js did not help me in order to somehow automate this, since it writes the current value to the variable and when the window is further resized, the ratio remains the same.
I will be glad to any solution to this problem, everything will be interesting for educational purposes)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander, 2015-09-23
@sarkis-tlt

Option 1 - handle the resize event
Option 2 - use vw

G
Gregory, 2015-09-23
@grigruss

div.some-block{
    background:url('some.img')no-repeat center;
    background-size: contain;
}

background-size
I think you know how to control the size of the block.

S
Stalker_darkway, 2015-09-23
@hronik87

The picture should not be written as a background, but pushed into html.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question