Style a Blog Layout with CSS Material.

Apr 02, 2024
41 Views

Creating a stylish blog layout involves understanding both HTML for the structure and CSS for styling. Below, I'll guide you through creating a basic yet modern blog layout. This example will include a header, a main content area with a sidebar, and a footer. I'll provide the HTML structure first, followed by the CSS to style it.
In this post, we will learn about CSS properties and layout patterns useful for styling content such as for a blog, including how to center website content about special selectors how margin collapsing works how to use Inspector to help create definitions for complex properties like linear-gradient how to make a circular image with one line of CSS. 
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Stylish Blog</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>

<header>
    <h1>My Stylish Blog</h1>
    <nav>
        <ul>
            <li><a href="#">Home</a></li>
            <li><a href="#">About</a></li>
            <li><a href="#">Contact</a></li>
        </ul>
    </nav>
</header>

<div class="container">
    <main>
        <article>
            <h2>Blog Post Title</h2>
            <p>Date: 2024-04-03</p>
            <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit...</p>
        </article>
        <!-- Add more articles here -->
    </main>

    <aside>
        <h3>About Me</h3>
        <p>This is a paragraph about the blog author...</p>
    </aside>
</div>

<footer>
    <p>Copyright © 2024 My Stylish Blog</p>
</footer>

</body>
</html>


/* Reset some default browser styles */
body, h1, h2, h3, p {
    margin: 0;
    padding: 0;
}

body {
    font-family: Arial, sans-serif;
    line-height: 1.6;
    color: #333;
}

header {
    background-color: #333;
    color: #fff;
    padding-top: 30px;
    padding-bottom: 15px;
    padding-left: 20px;
}

header h1 {
    margin-bottom: 10px;
}

nav ul {
    list-style: none;
    padding: 0;
}

nav ul li {
    display: inline;
    margin-right: 20px;
}

nav ul li a {
    color: #fff;
    text-decoration: none;
}

.container {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
    padding: 0 20px;
}

main {
    flex: 3;
}

aside {
    flex: 1;
    padding-left: 20px;
}

footer {
    background-color: #333;
    color: #fff;
    text-align: center;
    padding: 10px;
    position: relative;
    bottom: 0;
    width: 100%;
}

@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }

    aside {
        padding: 0;
    }
}

Enjoy this post?

Buy david joy a coffee

Sign in or Sign up to leave a comment.
Priscilla Chapman
June 07, 2024

Nice to meet your post

Buy David Joy a Coffee

☕
  • 1
  • 2
  • 3
  • 4
  • 5
90% of all proceeds go to Orphange/Olala

Gold Premium

$10.00
image

-Facility of Gold member. -It is proper and ethical for an AAFP member to indicate they have earned the AAFP's Degree of Fellow using the designation "FAAFP" or "Fellow", American Academy of Family Physicians" following name and degree designation or FAAFP may be used when appropriate.

  • Support me on a monthly & yearly basis

  • Unlock exclusive posts and messages

  • Explore premium gallery with content

Sign in First

Gold Vibe

$50.00
image

-Gold Vibes - Printing and Viewing DBA Labels, You can choose to have a DBA Label appear instead of the member’s existing membership designation code, the system allows you to move any existing memberships that use that code over to another code of your choice. Select a code and then Delete to move.

  • Support me on a monthly with yearly basis.

  • Unlock exclusive posts and comment.

  • Explore premium gallery with useful content.

Sign in First