HTML & CSS - Review And Responsive #100Devs

Class 06 of our Free Web Dev Bootcamp for folx affected by the pandemic. Join live T/Th 6:30pm ET leonnoel.com/twitch and ask questions here: leonnoel.com/discord

Skip to first slide
Slide 1 of 57

CSS -Review & Responsive

Leon Noel

"Uncle used to skim work, sellin' nicks at night
I was only 8 years old, watching Nick at Nite"

#100Devs


Slide 2 of 57

Agenda


Slide 3 of 57

Questions

About last class or life


Slide 4 of 57

Checking In

Like and Retweet the Tweet

!checkin


Slide 5 of 57

Friends?

Study Community Survey:

https://forms.gle/5qvnYVw3tA3Xaoye8


Slide 6 of 57

Alumni Twitter Space

Tomorrow Friday Jan. 28th 6:00pm ET


Slide 7 of 57

Submitting Work

Simple Site Lab and Layouts in codepen.io

Submit URLs here: https://forms.gle/rvPhDrbp56DQKgPaA

 


Slide 8 of 57

Sleep?


Slide 9 of 57

YOU OWE YOU

Text


Slide 10 of 57

What is the internet?


Slide 11 of 57

The Golden Rule

SEPERATION OF CONCERNS


Slide 12 of 57

HTML SYNTAX

(Spelling And Grammer Rules)

source: mdn


Slide 13 of 57

Time For Some

TAGS

not that kind...


Slide 14 of 57

Heading Elements (tags)

<h1> MOST IMPORTANT </h1>
<h2> .............. </h2>
<h3> .............. </h3>
<h4> .............. </h4>
<h5> .............. </h5>
<h6> .............. </h6>

SIZE DOES NOT MATTER


Slide 15 of 57

Other Text Elements

<p> Paragraph </p>
<span> Short text </span>
<pre> Preserves Whitespace </pre>

Slide 16 of 57

Containing Elements

<div> </div>
<section> </section>
<article> </article>
<aside> </aside>
<header> </header>
<footer> </footer>

Slide 17 of 57

Let's Mark Up

BBC Solution


Slide 18 of 57

CSS

Where does CSS go?


Slide 19 of 57

CSS

Use a separate CSS file

It is best practice to put CSS in it's own file and link to it from the <head> !

 

<link rel="stylesheet" href="css/style.css">

Slide 20 of 57

CSS BREAK DOWN

p{
  color: red;
  font-weight: bold;
}

The whole thing is called a rule.

The p is called a selector.

It is followed by a set of declarations in a declaration block


Slide 21 of 57

CSS BREAK DOWN

p{
  color: red;
  font-weight: bold;
}

What is this?


Slide 22 of 57
p{
  color: red;
  font-weight: bold;
}
p{
  color: blue;
}

CSS is read top to bottom

 

What comes below, can override what came above

 

This is called the Cascade


Slide 23 of 57

CSS BREAK DOWN

Why might we want to link to a separate CSS file?


Slide 24 of 57

Let's Review

Some Simple Styles


Slide 25 of 57

Color

h1{
  color: red;
}
h2{
  color: #FF0000;
}
p{
  color: rgba(255,0,0,1);
}
span{
  color: hsla(0, 100%, 50%,1);
}

Slide 26 of 57

Font-family

<head>
  <link href="https://fonts.googleapis.com/css2?family=Source+Sans+Pro:wght@300;
  400;700&display=swap" rel="stylesheet">
</head>
p{
  font-family: 'Source Sans Pro', 'Helvetica' sans-serif;
}

html

 

css


Slide 27 of 57

Font-weight

<head>
  <link href="https://fonts.googleapis.com/css2?family=Source+Sans+Pro:wght@300;
  400;700&display=swap" rel="stylesheet">
</head>
p{
  font-family: 'Source Sans Pro', 'Helvetica' sans-serif;
  font-weight: 700;
}

html

 

css


Slide 28 of 57

🛑 Stop 🛑

How to research?

 

https://lmgtfy.com/?q=italicize+text+html+mdn&s=d

 

🚨 Use the MDN 🚨

 

Use https://learn.shayhowe.com/html-css/


Slide 29 of 57

Let's Code

Some Basic CSS


Slide 30 of 57

Selecting By Relationship

section > p {
  color: red;
}

To select an element that is the direct descendent of another element use

parent > child

<section>
  <p>Hello, Twitch!</p>
</section>

Slide 31 of 57

Selecting By Relationship

section p {
  color: red;
}

To select an element that is inside of another element without being directly descended use parent element 

parent child

<section>
  <article>
    <p>Hello, Twitch!</p>
  </article>
</section>

Slide 32 of 57

Selecting By Relationship

p + p {
  color: red;
}

To select an element that is the next sibling use

 

previous sibling + next sibling

<section>
  <p>Hello, Twitch!</p>
  <p>Hello, Youtube!</p>
</section>

Slide 33 of 57

Let's Code

Some Relationships


Slide 34 of 57

IDs & Classes


Slide 35 of 57

IDs

#zebra {
  color: red;
}

IDs are used for selecting distinct elements

Only one id with the same value per document

#idName

<section>
  <p>Hello, Twitch!</p>
  <p id="zebra">Hello, Youtube!</p>
</section>

Slide 36 of 57

Classes

.bob {
  color: red;
}

Classes are for selecting multiple elements

Multiple with same value allowed per document

.className

<section>
  <p class="robot">Hello, Twitch!</p>
  <p id="zebra" class="bob">Hello, Youtube!</p>
  <p class="bob">Goodbye, Mixer!</p>
</section>

Slide 37 of 57

Specificity

#pizza .jumanjiOriginalMovie {
  color: red;
}
<section id="pizza">
  <p class="jumanjiOriginalMovie">Hello, Twitch!</p>
  <p id="car" class="hello">Hello, Youtube!</p>
  <p class="goodbye">Goodbye, Mixer!</p>
</section>

Slide 38 of 57

Specificity

#dietCoke p.dominosPizza.bob {
  color: red;
}
<section id="dietCoke">
  <p class="robot unicorn">Hello, Twitch!</p>
  <p id="zebra" class="bob dominosPizza">Hello, Youtube!</p>
  <p class="bob">Goodbye, Mixer!</p>
</section>

Slide 39 of 57

Specificity

#dietCoke #zebra {
  color: red !important;
}
<section id="dietCoke">
  <p class="robot unicorn">Hello, Twitch!</p>
  <p id="zebra" class="bob dominosPizza">Hello, Youtube!</p>
  <p class="bob">Goodbye, Mixer!</p>
</section>

Slide 40 of 57

Let's Code

Specificity Practice


Slide 41 of 57

The Box Model

By Matthias Apsel


Slide 42 of 57

Let's Draw

The Box Model


Slide 43 of 57

Let's Code

The Box Model


Slide 44 of 57

Let's Look

Starter Template


Slide 45 of 57

Time For Some

Layouts

not that kind...


Slide 46 of 57

🚨 Let's Talk About Floats 🚨


Slide 47 of 57

Floats

By css-tricks


Slide 48 of 57

Let's Code

Simple Layouts


Slide 49 of 57

Layout 1


Slide 50 of 57

Layout 2


Slide 51 of 57

Layout 3


Slide 52 of 57

Responsive Websites


Slide 53 of 57

Fixed Vs. Responsive

UPS.com Wayback Machine

Boston.com

vs.


Slide 54 of 57

Media Queries 

@media screen and (max-width: 600px) {
    h1 {
        color: blue;
    }
}

Slide 55 of 57

Let's Code

A Media Query


Slide 56 of 57

Homework

Make 15 minutes of pain responsive

Read: https://learn.shayhowe.com/advanced-html-css/


Slide 57 of 57

How can we make this responsive?