How can I accomplish full width page, 120px high NavBar, 3 Col Row, 40px high Footer, where an image in the central Col occupies 100% of remaining height between NavBar and Footer?
Or to put it another way 120px high div1, div2, 40px high div3 and make an image in div2 occupy 100% of remaining height between div1 and div3.
Hi @timoto, can you please post a design of your intended result? I’m still a bit unsure of what your goal is with the design. Without a screenshot or design of your desired outcome, it’s difficult to find a solution. TIA!
I’m really not sure how I can express this in simpler terms.
You see image 1 and 3 above ?
1 Is a vertical image and 3 is horizontal.
1, a vertical image, occupies 86vh with correct aspect ratio, Showing a circle, not an oval.
3, a horizontal image, occupies 100% width of the central column with correct aspect ratio. Showing a circle, not an oval.
However, I can only achieve that with 2 different classes. The class for 1 uses 86vh and the class for 3 uses 100% width.
I would like to achieve the same results with a single class, so that no matter whether the image is vertical or horizontal I will achieve results 1 or 3 respectively.
Can you think of a way that images, independent of vertical or horizontal aspect ratio can be displayed full height or width respectively in 1 class or other method of orientation relative code ?
The idea is to be able to display a slideshow of images in this way, displaying maximum height for vertical images and maximum width for horizontal images.
How about, how to make an image span 100% of it’s container’s width or height (which ever is the greater), without losing aspect ratio. Thus the image will resize when the browser resizes in height or width.
Hello @cyberdave , any thoughts on how to finish this off ? :
Make the image span either 100% of it’s container’s width or height vh (which ever is the greater of the image’s dimensions), without losing aspect ratio.
The intended behaviour being that image will resize when the browser resizes in height and/or width without losing aspect ratio.
Why not using a div that will be width and height 100% and just set a background for it? That would be the simpliest option I see here. Other than that you can’t resize in all directions an image and not expect it to stretch at some point. So a div that fits space entirely and background image with settings like cover, center would be sufficient.
Yes, but with width: 100% and max-height: 86vh, when you resize the browser window the image loses it’s aspect ratio.
This image is simply an example, it could be any photo if you like. The objective is to have a CSS rule to resize the image based on viewport without losing aspect ratio.
With columns set to 86vh, a div inside a column using height:100%; width: auto; background-image: Contain, I achieve the desired behaviour. http://test-heights.webflow.io/
Hi @thewonglv, if you replace your 1:1 image with something portrait or landscape, then resize the browser viewport, I think you will find that the image does not retain it’s aspect ratio.