html, body { height: 100%; margin: 0; display: flex; justify-content: center; align-items: center; background: transparent; overflow: hidden; } .container { position: relative; width: 100%; height: 100%; display: flex; align-items: flex-end; padding: 20px; box-sizing: border-box; } .title { background-color: rgba(0, 0, 0, 0.5); color: white; padding: 10px 20px; border-radius: 5px; font-size: 24px; } @media screen and (min-aspect-ratio: 16/9) { .container { width: 100%; height: 56.25vw; /* 100 / 16 * 9 = 56.25 */ } } @media screen and (max-aspect-ratio: 16/9) { .container { width: 177.78vh; /* 100 / 9 * 16 = 177.78 */ height: 100%; } }