How do you create responsive layouts

Learn how to create responsive layouts using CSS. Using techniques like media queries and flexible grid systems ensures that your website looks great on all devices.
responsive design, CSS, media queries, flexbox, grid layout

        <!DOCTYPE html>
        <html lang="en">
        <head>
            <meta charset="UTF-8">
            <meta name="viewport" content="width=device-width, initial-scale=1.0">
            <title>Responsive Layout Example</title>
            <style>
                body {
                    margin: 0;
                    font-family: Arial, sans-serif;
                }
                .container {
                    display: flex;
                    flex-wrap: wrap;
                }
                .box {
                    flex: 1 1 300px; /* Grow to fill space, with a minimum width of 300px */
                    margin: 10px;
                    padding: 20px;
                    background-color: #f4f4f4;
                    border: 1px solid #ccc;
                }
                @media (max-width: 600px) {
                    .box {
                        flex: 1 1 100%; /* Full width on small devices */
                    }
                }
            </style>
        </head>
        <body>
            <div class="container">
                <div class="box">Box 1</div>
                <div class="box">Box 2</div>
                <div class="box">Box 3</div>
            </div>
        </body>
        </html>
    

responsive design CSS media queries flexbox grid layout