CSS Website Layout - Detailed Overview

Introduction to CSS Website Layouts

Creating a layout for a website involves arranging elements in a visually appealing and functional manner. CSS provides various methods for layout design, including Flexbox, Grid, and traditional methods.

Examples of CSS Layout Techniques

Below are examples of a basic website layout using Flexbox:

/* General Styles */
body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f0f0f0;
}

header {
    background-color: #333;
    color: #fff;
    padding: 20px 0;
    text-align: center;
    margin-bottom: 20px;
}

h1 {
    margin: 0;
    font-size: 32px;
}

.container {
    margin: 0 auto;
    padding: 20px;
    background-color: #fff;
    border-radius: 10px;
    max-width: 1200px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

.main {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.sidebar {
    flex: 1;
    min-width: 200px;
    background-color: #f9f9f9;
    padding: 15px;
    border-radius: 5px;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
}

.content {
    flex: 3;
    background-color: #fff;
    padding: 15px;
    border-radius: 5px;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
}

footer {
    background-color: #333;
    color: #fff;
    padding: 15px;
    text-align: center;
    margin-top: 20px;
    border-radius: 5px;
}

Main Content Area

This is the main content area. Here you can place the primary content of your page.