Responsive Table Scroll
CSS
Hard
2 views
Problem Description
Make a wide table scroll horizontally on small screens.
Output Format
Print the HTML+CSS code in one block.
Constraints
Wrap table in a div with overflow-x: 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>
.tableWrap { overflow-x: auto; border: 1px solid #eee; border-radius: 12px; padding: 10px; max-width: 420px; }
table { border-collapse: collapse; min-width: 620px; }
th, td { border: 1px solid #ddd; padding: 8px; text-align: left; }
</style>
</head>
<body>
<div class='tableWrap'>
<table>
<tr><th>Topic</th><th>Level</th><th>Notes</th></tr>
<tr><td>HTML</td><td>Easy</td><td>Start here</td></tr>
<tr><td>CSS</td><td>Medium</td><td>Layout practice</td></tr>
</table>
</div>
</body>
</html>
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!