index.html
<!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 Example</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
align-items: center;
color: #333;
}
header {
width: 100%;
background-color: #4CAF50;
color: white;
padding: 1em;
text-align: center;
}
main {
display: flex;
flex-direction: row;
flex-wrap: wrap;
max-width: 1200px;
padding: 1em;
}
.box {
flex: 1 1 30%;
background-color: #f1f1f1;
margin: 10px;
padding: 20px;
text-align: center;
}
footer {
width: 100%;
background-color: #333;
color: white;
text-align: center;
padding: 1em;
position: fixed;
bottom: 0;
}
@media (max-width: 768px) {
.box {
flex: 1 1 45%;
}
header, footer {
padding: 0.8em;
}
}
@media (max-width: 480px) {
main {
flex-direction: column;
align-items: center;
}
.box {
flex: 1 1 100%;
}
header, footer {
font-size: 1.2em;
}
}
</style>
</head>
<body>
<header>
<h1>Responsive Web Design</h1>
<p>This is a simple responsive layout using media queries</p>
</header>
<main>
<div class="box">Box 1</div>
<div class="box">Box 2</div>
<div class="box">Box 3</div>
<div class="box">Box 4</div>
<div class="box">Box 5</div>
<div class="box">Box 6</div>
</main>
<footer>
<p>© 2024 Responsive Web Design Demo</p>
</footer>
</body>
</html>
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter