I would like to fit a div(red white box) in the center of the page. the black area represent the page layout the div needs to be height 100% when width cannot be stretched to keep the aspect ratio, or width 100% when height cannot be stretched. I am not sure what property I should use to calculate
It is also important that the div do not overflow the page so no scrollbar will be shown
I have tried: setting height: 100%; width: auto; or width: 100%; height: auto; both can achieve half of the target but I need to combine them together
*update: I have achieved with 1:1 aspect ratio with @Paulie_D 's answer, but what if the div needs to be 16:9 or 4:3?
