41

Click here to load reader

Responsive Web Design (April 18th, Los Angeles)

Embed Size (px)

Citation preview

Page 1: Responsive Web Design (April 18th, Los Angeles)

April 2017

Responsive Web Design

http://bit.ly/responsive-la

Wifi: CrossCamp.us Events

Page 2: Responsive Web Design (April 18th, Los Angeles)

About us

We train developers and data scientists through 1-on-1 mentorship and career prep

Page 3: Responsive Web Design (April 18th, Los Angeles)

About me

• Austen Weinhart

• UC Berkeley ’12

• Worked as a Front-End developer at Event Farm

• Worked on pages for clients such as Google, Facebook, Microsoft, and more

• Currently COO at Coding Autism, a coding bootcamp for adults on the autism spectrum

Page 4: Responsive Web Design (April 18th, Los Angeles)

About you

Why are you here?

• Do you want to work better with developers?

• Do you want to start working in tech?

• Do you have an idea that you want to build?

Programming experience?

• First lines of code will be written tonight

• Been self-teaching for 1-3 months

• Been at this for 3+ months

Page 5: Responsive Web Design (April 18th, Los Angeles)

Today’s goals

• Overview of responsive design

• Intro to HTML

• Intro to CSS

• Media queries

Page 6: Responsive Web Design (April 18th, Los Angeles)

Not goals

• Deep understanding of HTML/CSS/JavaScript

• Command line

• Deep dive into every responsive issue 😣

Page 7: Responsive Web Design (April 18th, Los Angeles)

What is HTML?

HTML is the content and structure of a webpage

Three key concepts: Tags Elements Attributes

Page 8: Responsive Web Design (April 18th, Los Angeles)

HTML Tags

Every tag starts with a “less than” sign and ends with a “greater than” sign

There are opening tags and closing tags. Closing tags have a backslash before the tag name.

<html> This is an HTML tag <body> This is a body tag

<h1>Hello world!</h1> This line has two H1 tags, one opening and one closing

</body> </html>

Page 9: Responsive Web Design (April 18th, Los Angeles)

HTML Elements

HTML elements usually consist of an opening tag, closing tag, and some content. <html>

<body> This element starts here and ends two lines below

<h1>Hello world!</h1> This is an HTML element

</body> </html>

Some consist of just a self-closing tag

<img src=“http://i.imgur.com/Th5404r.jpg">

Page 10: Responsive Web Design (April 18th, Los Angeles)

What is CSS?

Cascading Style Sheets determine the visual presentation of your HTML

webpages

Page 11: Responsive Web Design (April 18th, Los Angeles)

What is CSS?

Key concepts:

Selectors Property Value Declaration / Declaration block

Two problems we solve with CSS:

Presentation of specific elements Layout

Page 12: Responsive Web Design (April 18th, Los Angeles)

CSS Selectors

CSS selectors determine which HTML elements are targeted for specific styles:

p This selects all paragraph tags .header This selects HTML elements with the class “header” #navigation This selects HTML elements with the ID navigation p.header This selects paragraph tags with the header class

Selectors can be combined.

Page 13: Responsive Web Design (April 18th, Los Angeles)

CSS Properties

CSS properties determine what about the appearance you’re setting:

color This determines the font color font-family This lets you set the typeface as well as backup typefaces background-image This lets you set a background image for an element height This lets you set the height of an element

Page 14: Responsive Web Design (April 18th, Los Angeles)

CSS Properties

CSS properties determine what about the appearance you’re setting:

color This determines the font color font-family This lets you set the typeface as well as backup typefaces background-image This lets you set a background image for an element height This lets you set the height of an element

Page 15: Responsive Web Design (April 18th, Los Angeles)

CSS Properties

h1 {

color: red;

font-size: 36px;

}

Each property has a default value for a given element. When you write CSS, you over-ride that default value with a new value.

Page 16: Responsive Web Design (April 18th, Los Angeles)

Getting set up with CodePen

• If you don’t already have an account, create one. You can save one what you work on for later. It’s also a super helpful tool.

• We’ll be resizing our browsers to experiment with responsive design — use the side view:

https://codepen.io/accounts/signup

Page 17: Responsive Web Design (April 18th, Los Angeles)

What is responsive?

• Website/application that can quickly resize and respond to different browser sizes

• Styles are only applied based on breakpoints

• Desktop first

• Mobile first

• TV, desktop, laptop,

tablet, phone

Page 18: Responsive Web Design (April 18th, Los Angeles)

Start out with the basics: color changer

HTML:

<main></main>

CSS:

main { width: 250px; height: 250px; margin: 250px auto; background-color: blue; }

Page 19: Responsive Web Design (April 18th, Los Angeles)

Media query

CSS:

@media screen and (max-width: 800px) { main { background-color: red; }}

Page 20: Responsive Web Design (April 18th, Los Angeles)

Mobile first

CSS:

@media screen and (min-width: 800px) { main { background-color: red; }}

Page 21: Responsive Web Design (April 18th, Los Angeles)

Challenge

CSS:

3 more Breakpoints

300px or higher - yellow

500px or higher - green

1000px or higher - orange

Page 22: Responsive Web Design (April 18th, Los Angeles)

Easy resizing using %

CSS:

main { width: 90%; height: 250px; margin: 250px auto; background-color: blue; }

Page 23: Responsive Web Design (April 18th, Los Angeles)

Using constraints

CSS:

main { width: 90%; max-width: 800px; min-width: 250px; height: 250px; margin: 250px auto; background-color: blue; }

Page 24: Responsive Web Design (April 18th, Los Angeles)

The grid!

row

60px

6.25%

gutter

20px

2.08%

Page 25: Responsive Web Design (April 18th, Los Angeles)

The grid!

At a certain point the columns will stack on top of each other

Page 26: Responsive Web Design (April 18th, Los Angeles)

The grid!

Fork this starter pen, reverse engineer the code for a few minutes

http://codepen.io/tjstalcup/pen/NdYpLR

Page 27: Responsive Web Design (April 18th, Los Angeles)

The grid!

.row - container divs to house each row

.col-3 - these divs stretch across 3 columns (3*4 = 12)

Our actual content is contained in those columns

Page 28: Responsive Web Design (April 18th, Los Angeles)

.row styles

automatically centered

cannot go larger than 1000px

that padding ensures a 960px grid

.row { max-width: 1000px; padding-left: 20px; padding-right: 20px; margin: 0 auto;}

Page 29: Responsive Web Design (April 18th, Los Angeles)

Wait, what happened?

First rule ensures rows are as tall as their tallest child. Floats sometimesmess this up. This fixes that.

Clearfix makes sure all rows start on the next line

/* Clearfix */.row::before,.row::after { display: table; content: '';}

.row::after { clear: both;}

Page 30: Responsive Web Design (April 18th, Los Angeles)

cols

floating to the leftallows columns toline-up next toeach other

.col-3, .col-4, .col-6, .col-12 { float: left; padding-left: 1.04166666%; padding-right: 1.04166666%;}

1.04166666%?20px gutters (10 on ea. side)

10/960 = 0.01041666667

Page 31: Responsive Web Design (April 18th, Los Angeles)

cols

We are building Mobile First

On Mobile, all columns stack on top of each other

/* Mobile defaults */

.col-3, .col-4, .col-6, .col-12 { width: 100%;}

Page 32: Responsive Web Design (April 18th, Los Angeles)

cols

Any screen 640pxor higher, setup our flexible columns

3/12 = 0.25

4/12 = ?

6/12 = ?

12/12 = ?

@media only screen and (min-width: 640px) { /* 3 columns, 3/12 in % */ .col-3 { min-width: 25%; } .col-4 {

}

.col-6 {

}

.col-12 {

}

}

Page 33: Responsive Web Design (April 18th, Los Angeles)

Your turn!

• code up the remaining CSS for the grid

• add a row with three 4-width columns. Each column should have a colored box

• add a row with two 6-width columns. Each column should have a colored box

• add a row with one 12-width column. This column should have a colored box

Page 34: Responsive Web Design (April 18th, Los Angeles)

Finished preview

Page 35: Responsive Web Design (April 18th, Los Angeles)

Bootstrap/Foundation/Materialize

• Off the shelf Grid Systems

• Twitter Bootstrap

• Foundation

• Materialize

• Bloat

• Crutch

• Super Awesome

Page 36: Responsive Web Design (April 18th, Los Angeles)

What next?

• Keep practicing building websites and making them responsive

• Structured learning • Free online resources (JavaScript30,

FreeCodeCamp) • Low-cost online resources (CodeSchool,

TeamTreeHouse) • Night classes at community college or

universities • Coding bootcamps (full-time or part-time)

Page 37: Responsive Web Design (April 18th, Los Angeles)

More about Thinkful

You’ll learn concepts, practice with drills, and build capstone projects for your own portfolio — all guided by a personal mentor

Page 38: Responsive Web Design (April 18th, Los Angeles)

Our mentors

Mentors have, on average, 10+ years of experience

Page 39: Responsive Web Design (April 18th, Los Angeles)

Our results

Job Titles after GraduationMonths until Employed

Page 40: Responsive Web Design (April 18th, Los Angeles)

Try us out!

Try the program for two weeks, includes six mentor sessions - $50

Learn HTML/CSS/JavaScript

Option to continue onto web development bootcamp

Come talk to me if you’re interested (or email me at [email protected])

Page 41: Responsive Web Design (April 18th, Los Angeles)

Questions? email me at [email protected]