How to create a mixed column layout grid with CSS?

A mixed column layout grid in CSS is a responsive design technique that allows columns to adjust their width and arrangement based on screen size. This creates a flexible layout that works well on desktop, tablet, and mobile devices.

Syntax

.column {
    float: left;
    width: percentage;
    box-sizing: border-box;
}

@media screen and (max-width: breakpoint) {
    .column {
        width: new-percentage;
    }
}

Example: Responsive 4-Column Grid

The following example creates a 4-column layout that adapts to 2 columns on tablets and 1 column on mobile devices −

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
    body {
        font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
        margin: 0;
        padding: 20px;
    }
    
    * {
        box-sizing: border-box;
    }
    
    .col {
        color: white;
        float: left;
        width: 25%;
        padding: 15px;
        text-align: center;
    }
    
    .colContainer:after {
        content: "";
        display: table;
        clear: both;
    }
    
    .col h3 {
        margin: 0;
        padding: 20px;
        background-color: rgba(0, 0, 0, 0.2);
        border-radius: 5px;
    }
    
    @media screen and (max-width: 900px) {
        .col {
            width: 50%;
        }
    }
    
    @media screen and (max-width: 600px) {
        .col {
            width: 100%;
        }
    }
</style>
</head>
<body>
    <h1>Mixed Column Layout Grid</h1>
    <p>Resize the browser window to see the responsive behavior</p>
    
    <div class="colContainer">
        <div class="col" style="background-color: #9932e0;">
            <h3>Column 1</h3>
        </div>
        <div class="col" style="background-color: #0c7e78;">
            <h3>Column 2</h3>
        </div>
        <div class="col" style="background-color: #cf295b;">
            <h3>Column 3</h3>
        </div>
        <div class="col" style="background-color: #cc5b27;">
            <h3>Column 4</h3>
        </div>
    </div>
</body>
</html>
Four colorful columns appear side by side on desktop screens (25% width each). On tablet screens (below 900px), they arrange in 2 rows with 2 columns each (50% width). On mobile screens (below 600px), all columns stack vertically (100% width each).

Key Properties Explained

Property Purpose
box-sizing: border-box Includes padding in width calculations
float: left Positions columns side by side
clear: both Prevents float overlap with following content
@media queries Define responsive breakpoints

Conclusion

Mixed column layout grids use floats and media queries to create responsive designs. While modern CSS Grid and Flexbox offer better alternatives, this float-based approach remains useful for understanding responsive layout fundamentals.

Updated on: 2026-03-15T15:16:52+05:30

464 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements