Day 6 - Changing CSS with Javascript
Housekeeping
- Assessment announcements
- Assignment 2
- Weight: 5%
- Due: October 28th
- Achievements Round 2
- Weight: 6%
- Due: October 31st
- Assignment 2
1. Assessment and Week 8 overview
Week 8 Schedule:
- Today - Changing CSS with Javascript
- Tuesday - Conditionals and form controls
- Wednesday - Loops!
- Thursday - Objects and JSON
- Friday - Fetching data asynchronously
Assessments
Element.classList
API
2.
Materials
Demo: Dark mode toggle
Let’s build a checkbox that adds/removes a dark-mode
class on the <body>
element that changes a page’s color
and background-color
.
Activity
In groups of 2-3, create a button or checkbox that:
- uses
classList
to add/remove ahide
class on another element; - makes a paragraph (or other page content) disappears and appears when a
hide
class is added/removed.
3. CSS Variables
Materials
Demo: Colour slider
If we have time, let’s add a colour slider that changes the colour angle of both light and dark modes at the same time.
4. Lab Time
Prep
CSS Variables
- Reading list:
- Watch list:
- CSS Variables in 100 Seconds by Fireship
- CSS Variables - An introduction to CSS custom properties by Kevin Powell
Element.classList
- Reading list:
- MDN:
Element.classList
- MDN:
- Watch list:
- Controlling a CSS ClassList with JavaScript by Steve Griffith
Search list
- “dark mode css variables”