I am trying to create a page with the following properties that will be used as digital signage:
- Page height - viewport height (
100vh ), so scrolling is not possible. - Page arranged in full-width rows
- All lines except the last are static (have predefined content)
- The last line (which will contain the image slide show) should fill the remaining space in the viewport.
Here is what I still have:
body { margin: 0; } div#container { display: flex; flex-direction: column; height: 100vh; } div.red { height: 100px; background-color: red; flex: 0 0 auto; } div.blue { height: 150px; background-color: blue; flex: 0 0 auto; } div.green { background-color: green; flex: 0 1 auto; } img { max-height: 100%; }
<div id="container"> <div class="red"></div> <div class="blue"></div> <div class="green"> <img src="http://lorempixel.com/200/300/"> </div> </div>
https://jsfiddle.net/62qqnx3m/6/
Obviously, this does not work because flex does not reduce the size of the image to the desired size.
I can remove flex: 0 0 auto from the first two divs, but instead they are shortened.
How can I make the green div / image occupy exactly what remains, no more, no less?
Therefore, if a higher image were set, it would be reduced even more to fit.
And if the image is smaller than the available space, it should just be displayed, and the background div is still filling the available space.
It seems that max-height:100% for this would be great, but that also doesn't work.
In addition, I saw examples of how to do this horizontally (which I also need, but I have less problems), but I can’t figure out how to translate this into vertical scaling.
source share