Answer the question
In order to leave comments, you need to log in
Crop image to screen height CSS?
Hello.
Stuck at the moment.. There is a DIV and there is an image that should not exceed the height of the screen.
It is necessary that the picture be rubber in relation to the height of the monitor and that it does not exceed it. The div must be followed by another div. It all needs to be made rubber somehow. Absolute values are not very suitable, because the picture can change, as well as its dimensions.
Something similar is position: fixed, but I don't want the image to be fixed.
What do you advise? :)
Answer the question
In order to leave comments, you need to log in
htmlbook.ru/css/background-size
Scales the image proportionally so that its width or height equals the width or height of the box.
#content {
height: 100%;
}
#content img{
max-height:100%;
}
<body>
<div id="content">
<img src="images/abc.jpg">
</div>
</body>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question