Responsive Iframe Ratio
CSS
Hard
3 views
Problem Description
Make an iframe responsive using an aspect ratio wrapper.
Output Format
Print the HTML+CSS code in one block.
Constraints
Use aspect-ratio on a wrapper and make iframe fill it.
Official Solution
<!doctype html>
<html lang='en'>
<head>
<meta charset='utf-8'>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<title>meetcode</title>
<style>
.frame { width: min(92%, 720px); aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; border: 1px solid #eee; }
iframe { width: 100%; height: 100%; border: 0; display: block; }
</style>
</head>
<body>
<div class='frame'>
<iframe title='meetcode preview' src='https://meetcode.com'></iframe>
</div>
</body>
</html>
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!