Skip to content

Commit 3486a7b

Browse files
authored
Merge pull request #205 from codeharborhub/dev-1
added css docs
2 parents 605bf46 + 7a90cb8 commit 3486a7b

File tree

13 files changed

+886
-17
lines changed

13 files changed

+886
-17
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"label": "CSS",
3+
"position": 2,
4+
"link": {
5+
"type": "generated-index",
6+
"description": "Getting started with CSS, how to add style, color, and personality to your HTML."
7+
}
8+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
---
2+
sidebar_position: 3
3+
title: "Colors & Backgrounds"
4+
sidebar_label: "Colors & Backgrounds"
5+
description: "Learn how to use Hex, RGB, and background images to make your site pop."
6+
---
7+
8+
In the physical world, paint comes in buckets. In the digital world, paint comes in **codes**. To build a professional-looking site, you need to understand how computers "read" color and how to layer backgrounds to create depth.
9+
10+
## Three Ways to Define Color
11+
12+
While you can use names like `red` or `skyblue`, there are actually 140 named colors in HTML. Professionals need more variety, so we use these three systems:
13+
14+
### 1. Hexadecimal (The Industry Standard)
15+
Hex codes start with a `#` followed by 6 characters. It is the most common way to share colors between designers and developers.
16+
* **Example:** `#ff5733` (A vibrant orange).
17+
18+
### 2. RGB (The Digital Screen Way)
19+
Stands for **Red, Green, Blue**. It tells the screen how much of each light to mix.
20+
* **Example:** `rgb(255, 87, 51)`
21+
22+
### 3. RGBA (The Transparency Trick)
23+
The `a` stands for **Alpha**. This allows you to make colors see-through!
24+
* **Value:** `0.0` (invisible) to `1.0` (fully solid).
25+
* **Example:** `rgba(0, 0, 0, 0.5)` (A 50% transparent black).
26+
27+
## Beyond Solid Colors: Backgrounds
28+
29+
You can style the background of any element (a button, a section, or the whole page) using the `background` properties.
30+
31+
### Background Images
32+
33+
Want a cool photo behind your text?
34+
35+
```css
36+
.hero-section {
37+
background-image: url('ocean.jpg');
38+
background-size: cover; /* Makes the image fit the whole area */
39+
background-position: center;
40+
}
41+
42+
```
43+
44+
### Linear Gradients
45+
46+
Gradients are a smooth transition between two or more colors. They look very modern in 2026!
47+
48+
```css
49+
.gradient-box {
50+
background: linear-gradient(to right, #ff7e5f, #feb47b);
51+
}
52+
53+
```
54+
55+
## Interactive CodePen: Color Mixer
56+
57+
Check out how these different color types look in real-time. Try changing the `background-color` of the second box to a `rgba` value to see it become transparent!
58+
59+
<CodePenEmbed
60+
title="CSS Color Systems"
61+
penId="qEaWQNW"
62+
/>
63+
64+
### Challenge Tasks:
65+
66+
1. Find a color you love on [Adobe Color](https://color.adobe.com/) and copy the **Hex code**.
67+
2. Apply that Hex code to the `h1` in the CodePen.
68+
3. Try making the background a `linear-gradient`.
69+
70+
## Accessibility: The Contrast Rule
71+
72+
As a developer at **CodeHarborHub**, you have a responsibility to make sure everyone can read your site.
73+
74+
:::danger Don't do this!
75+
Never put light gray text on a white background. It's impossible for people with low vision to read.
76+
:::
77+
78+
:::tip
79+
Always use a [Contrast Checker](https://webaim.org/resources/contrastchecker/) to ensure your text "pops" against the background.
80+
:::
81+
82+
## Summary Checklist
83+
84+
* [x] I know that Hex codes start with `#`.
85+
* [x] I can use `rgba()` to create transparent overlays.
86+
* [x] I understand that `background-size: cover` helps images fit properly.
87+
* [x] I checked my color contrast for accessibility.
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
---
2+
sidebar_position: 10
3+
title: "Final Challenge: Style Your Portfolio"
4+
sidebar_label: CSS Challenge
5+
description: "The ultimate test! Apply all your CSS skills to your personal portfolio."
6+
---
7+
8+
It’s time to take your "plain" HTML Portfolio and give it a professional makeover. This is the exact process developers use: starting with a wireframe, building the structure, and then adding the "visual polish."
9+
10+
## Step 1: The Design Strategy
11+
12+
Before writing code, we need a plan. We will use a **Mobile-First** strategy. This means we will style the mobile version first, then use Media Queries to adjust it for Desktop.
13+
14+
## Step-by-Step Implementation
15+
16+
### Step 1: Reset & Setup
17+
18+
At the very top of your `style.css`, add the "Universal Reset." This ensures every browser starts with the same clean slate.
19+
20+
```css title="style.css"
21+
* {
22+
margin: 0;
23+
padding: 0;
24+
box-sizing: border-box; /* The layout savior! */
25+
}
26+
27+
body {
28+
font-family: 'Segoe UI', sans-serif;
29+
line-height: 1.6;
30+
color: #333;
31+
background-color: #f4f4f4;
32+
}
33+
34+
```
35+
36+
### Step 2: Flex the Navigation
37+
38+
Use Flexbox to move your Logo to the left and your Links to the right.
39+
40+
```css title="style.css"
41+
nav {
42+
display: flex;
43+
justify-content: space-between;
44+
align-items: center;
45+
padding: 20px 5%;
46+
background: #2d3436;
47+
color: white;
48+
}
49+
50+
nav a {
51+
color: white;
52+
text-decoration: none;
53+
margin-left: 20px;
54+
}
55+
56+
```
57+
58+
### Step 3: The "Hero" (About) Section
59+
60+
This is the first thing people see. We want it centered and impactful.
61+
62+
```css title="style.css"
63+
#about {
64+
display: flex;
65+
flex-direction: column; /* Stacked for mobile */
66+
align-items: center;
67+
text-align: center;
68+
padding: 50px 20px;
69+
}
70+
71+
#about img {
72+
border-radius: 50%; /* Makes your photo a circle */
73+
border: 5px solid #0984e3;
74+
width: 150px;
75+
margin-bottom: 20px;
76+
}
77+
78+
```
79+
80+
### Step 4: The Skills Grid
81+
82+
We’ll use Flexbox to make your skills look like neat badges.
83+
84+
```css title="style.css"
85+
#skills ul {
86+
display: flex;
87+
flex-wrap: wrap;
88+
justify-content: center;
89+
list-style: none;
90+
}
91+
92+
#skills li {
93+
background: #0984e3;
94+
color: white;
95+
padding: 10px 20px;
96+
margin: 10px;
97+
border-radius: 20px;
98+
font-weight: bold;
99+
}
100+
101+
```
102+
103+
### Step 5: Make it Responsive
104+
105+
Now, add a Media Query to make the "About" section look better on big screens.
106+
107+
```css title="style.css"
108+
@media (min-width: 768px) {
109+
#about {
110+
flex-direction: row; /* Side-by-side for desktop */
111+
text-align: left;
112+
justify-content: center;
113+
}
114+
115+
#about img {
116+
margin-right: 40px;
117+
margin-bottom: 0;
118+
}
119+
}
120+
121+
```
122+
123+
## See the Final Result on CodePen
124+
125+
Check out how these steps come together in this interactive demo. Try clicking the "Mobile View" in CodePen to see how the layout shifts!
126+
127+
<CodePenEmbed
128+
title="Final CSS Portfolio Challenge"
129+
penId="ByLBGXV"
130+
/>
131+
132+
:::success YOU ARE NOW A CSS STYLIST!
133+
You've completed the CSS Basics module. You have the power to take any boring HTML page and turn it into a beautiful, responsive experience.
134+
135+
**What's next?**
136+
Would you like to start **JavaScript: The Brains of the Web**, or would you like to explore **CSS Grid** for even more complex layouts?
137+
:::
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
---
2+
sidebar_position: 7
3+
title: "Flexbox Part 1: Modern Layouts"
4+
sidebar_label: "Flexbox (Basics)"
5+
description: "Learn the modern way to align and distribute space on your page."
6+
---
7+
8+
Imagine you have a row of boxes. You want to center them, space them out evenly, or turn them into a column. Doing this with margins is a nightmare. Doing it with **Flexbox** is easy!
9+
10+
Flexbox is a "One-Dimensional" layout system. This means it handles content in **either** a row or a column at a time.
11+
12+
## The Parent & The Children
13+
14+
Flexbox works on a **Parent-Child** relationship.
15+
1. **Flex Container (Parent):** The box that holds everything.
16+
2. **Flex Items (Children):** The boxes inside.
17+
18+
To start the magic, you simply tell the Parent:
19+
20+
```css
21+
.container {
22+
display: flex;
23+
}
24+
25+
```
26+
27+
## The Two Axes
28+
29+
This is the most important concept to visualize:
30+
31+
* **Main Axis:** Usually horizontal (Left to Right).
32+
* **Cross Axis:** Usually vertical (Top to Bottom).
33+
34+
## The "Big Three" Properties
35+
36+
Once you set `display: flex`, you use these three properties on the **Parent** to control the children:
37+
38+
### 1. `justify-content` (Main Axis)
39+
40+
Moves items horizontally (if in a row).
41+
42+
* `flex-start`: Items at the beginning.
43+
* `center`: Items in the middle! (Finally!)
44+
* `space-between`: Items push to the edges with equal space between them.
45+
46+
### 2. `align-items` (Cross Axis)
47+
48+
Moves items vertically.
49+
50+
* `flex-start`: Top.
51+
* `center`: Perfect vertical centering.
52+
* `stretch`: Stretches items to fill the height.
53+
54+
### 3. `flex-direction`
55+
56+
Changes the direction of the flow.
57+
58+
* `row`: Default (Side-by-side).
59+
* `column`: Stacks items vertically like a list.
60+
61+
## Interactive CodePen: Flexbox Playground
62+
63+
In this Pen, try changing `justify-content` to `space-around`. See how the boxes react!
64+
65+
<CodePenEmbed
66+
title="Flexbox Basics Playground"
67+
penId="ogzvQyx"
68+
/>
69+
70+
### Challenge Tasks:
71+
72+
1. Set `justify-content: center` AND `align-items: center`. You have now achieved the **"Holy Grail" of web design**: Perfect centering!
73+
2. Change `flex-direction` to `column`.
74+
3. Try `justify-content: space-evenly`.
75+
76+
## Why use Flexbox?
77+
78+
* **No more floats:** You don't need to use old, broken layout methods.
79+
* **Responsive:** Items can shrink or grow to fit the screen.
80+
* **Simplicity:** Centering takes seconds, not hours.
81+
82+
## Summary Checklist
83+
84+
* [x] I know that `display: flex` goes on the **Parent**.
85+
* [x] I can use `justify-content` to move items along the Main Axis.
86+
* [x] I can use `align-items` to center items vertically.
87+
* [x] I understand the difference between a `row` and a `column`.

0 commit comments

Comments
 (0)