Maintain aspect ratio according to width and height
问题 It is possible to fit and center a square div in the viewport and always maintain it\'s aspect ratio according to width and height ? Requirements : only CSS the size of the square must adapt to the smallest dimension (width or height) of viewport regardless of the orientation (landscape or portrait) of the viewport. the square must be centered horizontaly and verticaly in the viewport Example: 回答1: To maintain the aspect ratio of a div according to width and height in the viewport, you can