4. Demonstrate Responsive Web Design using Media Queries to create a webpage.
Fri Nov 15 2024 17:06:58 GMT+0000 (Coordinated Universal Time)
Saved by
@webtechnologies
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Responsive Web Design</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
}
header {
background-color: #3498db;
color: white;
padding: 20px;
text-align: center;
}
.container {
padding: 20px;
}
.content {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 20px;
}
.content div {
background-color: #2980b9;
color: white;
text-align: center;
padding: 20px;
border-radius: 8px;
}
@media (max-width: 768px) {
.content {
grid-template-columns: repeat(2, 1fr);
}
}
@media (max-width: 480px) {
.content {
grid-template-columns: 1fr;
}
header {
padding: 15px;
}
.content div {
font-size: 14px;
}
}
</style>
</head>
<body>
<header>
<h1>Responsive Web Design</h1>
</header>
<div class="container">
<div class="content">
<div>Item 1</div>
<div>Item 2</div>
<div>Item 3</div>
</div>
</div>
</body>
</html>
content_copyCOPY
Comments