Toggle navigation
☰
HTML
CSS
Scripting
Database
<!DOCTYPE html> <html> <head> <title>Mobile-Friendly Example</title> <style> body { font-family: sans-serif; margin: 0; padding: 0; background-color: #f4f4f4; } .container { padding: 20px; } .card { background-color: white; padding: 20px; margin-bottom: 20px; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); } /* Desktop layout: Elements sit side-by-side */ .layout-wrapper { display: flex; gap: 20px; } .main-content { flex: 2; } .sidebar { flex: 1; } /* Mobile layout: Breakpoint at 600px */ @media (max-width: 600px) { .layout-wrapper { flex-direction: column; /* Stack vertically instead of horizontally */ } .card { padding: 15px; /* Slightly smaller padding for smaller screens */ } } </style> </head> <body> <div class="container"> <h2>Responsive Layout Showcase</h2> <p>Resize your browser window (or view on mobile) to see the layout stack vertically.</p> <div class="layout-wrapper"> <div class="main-content"> <div class="card"> <h3>Main Article</h3> <p>This section takes up more space on wide screens, but fills the whole width on smaller devices.</p> </div> </div> <div class="sidebar"> <div class="card"> <h3>Sidebar Widget</h3> <p>This widget sits to the right on desktops, but drops underneath the main article on mobile phones.</p> </div> </div> </div> </div> </body> </html>