Responsive Image Fit
CSS
Easy
3 views
Problem Description
Make an image never overflow its container.
Output Format
Print the HTML+CSS code in one block.
Constraints
Use max-width: 100% and height: auto.
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>
.wrap { max-width: 360px; border: 1px solid #eee; padding: 10px; }
img { max-width: 100%; height: auto; display: block; }
</style>
</head>
<body>
<div class='wrap'>
<img src='wide.jpg' alt='meetcode screenshot'>
</div>
</body>
</html>
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!