← Back to all tutorials
Django TutorialEpisode 31

Styling the App (part 2)

Complete the styling — add form styles, button styles, footer, article detail page, and responsive breakpoints for mobile.

Styling the App (part 2)

Let us finish the styling with forms, buttons, the detail page, footer, and responsive design.

Form Styles

/* Forms */
form p {
    margin-bottom: 15px;
}

form label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #555;
}

form input[type="text"],
form input[type="password"],
form textarea,
form select {
    width: 100%;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 1em;
    transition: border-color 0.3s;
}

form input:focus,
form textarea:focus {
    border-color: #0c4b33;
    outline: none;
}

Buttons

/* Buttons */
.btn, button[type="submit"] {
    background: #0c4b33;
    color: white;
    padding: 10px 25px;
    border: none;
    border-radius: 5px;
    font-size: 1em;
    cursor: pointer;
    transition: background 0.3s;
}

.btn:hover, button[type="submit"]:hover {
    background: #0a3d2a;
}

.btn-danger {
    background: #e74c3c;
}

.btn-danger:hover {
    background: #c0392b;
}

Article Detail

/* Article Detail Page */
.article-detail {
    background: white;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.article-detail h2 {
    font-size: 2em;
    margin-bottom: 10px;
    color: #0c4b33;
}

.article-detail .meta {
    color: #888;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.article-detail .body {
    line-height: 1.8;
    font-size: 1.1em;
}

.article-detail img.thumb {
    max-width: 100%;
    border-radius: 8px;
    margin-bottom: 20px;
}

Footer

/* Footer */
footer {
    text-align: center;
    padding: 30px;
    color: #888;
    margin-top: 40px;
}

Responsive Design

/* Mobile */
@media (max-width: 768px) {
    nav {
        flex-direction: column;
        text-align: center;
    }
    nav .nav-links {
        margin-top: 10px;
    }
    nav .nav-links a {
        margin: 0 10px;
    }
    .content {
        padding: 0 15px;
    }
    .article-detail {
        padding: 20px;
    }
}

Key Takeaways

  • Consistent form and button styling creates a professional look
  • Focus states on inputs improve accessibility
  • Responsive breakpoints ensure the site works on mobile
  • The complete blog now has a polished, production-ready appearance