Skip to content

Instantly share code, notes, and snippets.

@kingluddite
kingluddite / override-bootstrap.md
Created September 21, 2024 12:44
custom css on Bootstrap

To override Bootstrap's default button color with custom styles, you can use an external stylesheet or inline styles. Let me show you an example of how to override the button's default styling using a custom CSS class.

Step 1: Create a Custom CSS Class

You’ll need to add your custom styles either in the <style> section of the HTML document or in a separate CSS file. For this example, we’ll override the .btn-primary button color.

Example Before Overriding Bootstrap Button Color:

Here’s the standard Bootstrap button without any custom styles:

@kingluddite
kingluddite / using-bootstrap-offset.md
Created September 21, 2024 12:33
Example using Bootstrap offset

The offset classes in Bootstrap allow you to add spacing to the left of a column by shifting it horizontally. This is useful when you want to center or space out columns without using custom CSS.

Before Using the offset Class:

Here’s a basic layout with two columns, without any offsets:

<!DOCTYPE html>
<html lang="en">
@kingluddite
kingluddite / bootstrap-order-example.md
Last active September 21, 2024 12:41
example of using the order class in bootstrap

The order class in Bootstrap allows you to control the order of columns regardless of their placement in the HTML. This can be really useful for responsive design when you want to rearrange columns for different screen sizes.

Before Using the order Class:

Here’s an example of a simple two-column layout without any ordering:

<!DOCTYPE html>
<html lang="en">
<head>
@kingluddite
kingluddite / step-by-step-bs.md
Created September 21, 2024 12:24
How to use bootstrap with a simple example

To demonstrate Bootstrap's functionality step-by-step, let's outline the process with HTML and Bootstrap. I'll provide a brief description and code examples for each step:

Step 1: A Blog Page with Just HTML

We'll start by creating a simple blog page with only HTML, no styling yet.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
@kingluddite
kingluddite / bootstrap-5-breadcrumbs.md
Created September 19, 2024 17:03
Review of Bootstrap 5 Breadcrumbs

In Bootstrap 5, breadcrumbs are used to indicate the current page's location within a navigational hierarchy. They visually show the path from the homepage to the current page and allow users to easily navigate back to previous pages.

Key Features:

  • Breadcrumbs are built using an ordered list (<ol>) with the class .breadcrumb.
  • Each breadcrumb item is wrapped inside an <li> element with the class .breadcrumb-item.
  • The current page (or the active item) has an additional class .active, and by default, it’s styled to look inactive (i.e., not clickable).

Basic Example:

@kingluddite
kingluddite / bootstrap-5-grid.md
Created September 17, 2024 13:48
Understanding Bootstrap 5 Grid

Bootstrap 5’s grid system is a powerful and flexible way to layout and align content. It uses a 12-column layout that can be adjusted for different screen sizes (responsive design) using predefined classes. The grid system is built on flexbox and provides an easy way to structure your page.

Basic Concepts:

  • Containers: These are the wrappers for the rows and columns. Bootstrap has two types: .container (fixed-width) and .container-fluid (full-width).
  • Rows: A row (.row) is a horizontal group of columns.
  • Columns: Columns are the building blocks of the grid. You define columns with the class .col and use numbers to specify how many of the 12 available columns the element should span (e.g., .col-6 for half-width columns).

Practical Example:

@kingluddite
kingluddite / three-ways-to-add-css.md
Created September 11, 2024 13:49
Three ways to add CSS to an HTML document

There are three main ways to add CSS to an HTML file, each with its own use cases depending on the project needs and scope:

1. Inline CSS

  • CSS is applied directly to HTML elements using the style attribute.
  • Example:
    <p style="color: blue; font-size: 18px;">This is a blue paragraph.</p>
  • Use Case: Best for quick, small changes to a specific element. However, it's not ideal for larger projects since it can become difficult to maintain and violates the separation of content and style.
@kingluddite
kingluddite / css-specificity.md
Created September 10, 2024 12:42
How does Specificity work in CSS?

In CSS, specificity determines which styles are applied when multiple CSS rules target the same HTML element. It’s like a ranking system that helps the browser decide which rule to use when there’s a conflict.

Basic Rule:

The more specific a rule is, the higher priority it has over other, less specific rules. CSS specificity is calculated based on the types of selectors used in a rule.

How Specificity Works:

Selectors in CSS can have different "weights" based on their type. The more specific a selector, the higher its weight, and the more likely it is to be applied over other styles.

Specificity Levels:

Here’s how different selectors contribute to specificity:

@kingluddite
kingluddite / css-box-model.md
Created September 10, 2024 12:38
Explain the css box model

The CSS Box Model is a fundamental concept that defines how elements are structured and rendered on a webpage. It describes the space that each HTML element occupies, consisting of four layers. Here’s a breakdown:

  1. Content: This is the actual content inside the element, such as text, images, or other media.

  2. Padding: Padding is the space between the content and the element’s border. It creates an area inside the element around the content, but it does not have a background (unless specified).

  3. Border: This is a line that surrounds the padding and the content. It can be styled (e.g., thickness, color, solid or dashed lines). Borders can be removed entirely, or customized as needed.

  4. Margin: Margin is the space outside the border, creating a gap between this element and others around it. Margins are transparent and can collapse (e.g., if two elements have margins next to each other).

@kingluddite
kingluddite / detail-explanation-flexbox.md
Last active July 10, 2024 13:18
explaining flexbox in greater detail

How Flexbox is used in your CSS to create a responsive design for the flower cards.

Flexbox in the Card Container

CSS

.card {
  display: flex; /* This activates flexbox on the .card container */
  flex-wrap: wrap; /* This allows the child elements to wrap onto the next line if there isn't enough space */
 justify-content: center; /* This centers the child elements horizontally within the container */