learn css3 for beginners at rocket speed

58
CSS at rocket speed inarocket.com FOR BEGINNERS

Upload: in-a-rocket

Post on 01-Nov-2014

3.885 views

Category:

Engineering


6 download

DESCRIPTION

http://inarocket.com Learn CSS3 fundamentals as fast as possible. CSS syntax, why use CSS, inline / embeded / external styles, measurements, selectors (universal, element, id, class, descendent, child, sibbling, attribute, pseudo-class, nth-child), inheritance, gradients, shadows, rounded corners, browser support, etc.

TRANSCRIPT

Page 1: Learn CSS3 for beginners at rocket speed

CSSat rocket speed

inarocket.com

FOR BEGINNERS

Page 2: Learn CSS3 for beginners at rocket speed

Learn front-end development at rocket speed

inarocket.com

Page 3: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

WHAT DO YOU NEED TO START

COMPLETED

Page 4: Learn CSS3 for beginners at rocket speed

What is CSS

Page 5: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

WHAT IS CSS

C S SCascading Style Sheets

What means “cascading”? Don’t worry. We will learn about it later.

Page 6: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

WHAT IS CSS

+HTMLContent structure

JAVASCRIPTContent behavior

CSSContent presentation +

Page 7: Learn CSS3 for beginners at rocket speed

Why use CSS

Page 8: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

WHY USE CSS

A few years ago: every HTML file had a mix of content + styles. Problem: to update any style in a web site, you had to modify all the HTML files.

website

content + styles

HTML

content + styles

HTML

content + styles

HTML

content + styles

HTML

content + styles

HTML

content + styles

HTML

content + styles

HTML

content + styles

HTML

Client

You

I don’t like my website’s headers in black. Could you please change them to blue?

Noooooooooooooooooooooooooo!!!!!!!!!! It will take me hours…

Page 9: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

WHY USE CSS

Present day: HTML files only have content and are linked to independent CSS files (styles). Solution: to update any style in a web site, you only have to modify your CSS.

website

styles

CSS

content

HTML

content

HTML

content

HTML

content

HTML

Client

You

I don’t like my website’s headers in black. Could you please change them to blue?

Sure! Done in a minute.

Page 10: Learn CSS3 for beginners at rocket speed

What do you need

Page 11: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

WHAT DO YOU NEED TO START

+EDITORe.g. Notepad

BROWSERe.g. Firefox

FOLDERSProject structure +

Page 12: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

WHAT DO YOU NEED TO START: FOLDERSCreate the folders that will contain the web project on your computer. !

projectname: • img (will contain images) • css (will contain stylesheets) • js (will contain JavaScripts)

projectname

img

css

js

Here are the HTML files that you created in the previous course.

Important rules for naming folders and files. • Never use spaces. • Never use special characters (%, *, +, etc.). • Avoid uppercases.

Page 13: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

WHAT DO YOU NEED TO START: EDITOR

Editor: pre-installed

You can just use any text editor preinstalled in your computer.

Notepad TextEdit Gedit

Editor: additional

There are other editors but you won't need their advanced features for this course.

Sublime Text Atom

Page 14: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

WHAT DO YOU NEED TO START: BROWSER

Browser: pre-installed

You can just use any preinstalled browser in your computer.

Explorer Safari Firefox

Browser: additional

There are other browsers that you can also install in your computer.

Chrome Firefox Opera

Page 15: Learn CSS3 for beginners at rocket speed

Quick start

Page 16: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

QUICK STARTLet’s get started with: • two HTML files linked to • a CSS file.

projectname

img

css

js

page1.html

HTML

page2.html

HTML

style.css

CSS

Page 17: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

QUICK START: HTML FILES

<!doctype  html>  <html>      <head>      <title>Page  One</title>      <link  rel=“stylesheet”  href=“css/style.css”>      </head>      <body>      <h1>This  is  page  1</h1>      <p>Here  goes  a  paragraph</p>      </body>  </html>

Editor (what you should write)

Save as page1.html

<!doctype  html>  <html>      <head>      <title>Page  Two</title>      <link  rel=“stylesheet”  href=“css/style.css”>      </head>      <body>      <h1>This  is  page  2</h1>      <p>Here  goes  a  paragraph</p>      </body>  </html>

Editor (what you should write)

Save as page2.html

Page 18: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

QUICK START: CSS SYNTAX

p {color: blue}Property

Selector Declaration

Value

With this code all paragraphs are shown in blue

Page 19: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

QUICK START: CSS FILE

p  {color:  blue}

Editor (what you should write)

Save as style.css

Browser

This is page 1 Here goes a paragraph

(what you should view)

Open page1.html in your browser(in your css folder)

Page 20: Learn CSS3 for beginners at rocket speed

Selectors

Page 21: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

WHAT IS A CSS SELECTOR

p {color: blue}Property

Selector Declaration

Value

With this code all paragraphs are shown in blue. Don’t worry about the declaration. We will learn how to use it later.

A CSS selector allows you to select the content you want to style.

Page 22: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

SELECTOR TYPES

Element Selector

Descendant Selector

Child Selector

Id Selector

Class Selector

Element Specific Selector

General Sibling Selector

Adjacent Sibling Selector

Attribute Selector

Pseudo-class Selector

Dynamic Pseudo-class Selector

Structural Pseudo-class Selector

Nth-child Selector

Universal Selector

Element Selector

Page 23: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

ELEMENT SELECTOR

With this code all paragraphs are shown in blue

A CSS element selector allows you to select and style a HTML element.

p {color: blue}

Syntax element {style properties}

Page 24: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

ELEMENT SELECTOR

<p>Web  design  rocks!</p>  <p>Hello  world.</p>

HTML CSS

p  {color:  blue}

Browser

Web design rocks! Hello world.

Page 25: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

SELECTOR TYPES

Element Selector

Descendent Selector

Child Selector

Id Selector

Class Selector

Element Specific Selector

General Sibling Selector

Adjacent Sibling Selector

Attribute Selector

Pseudo-class Selector

Dynamic Pseudo-class Selector

Structural Pseudo-class Selector

Nth-child Selector

Universal Selector

Descendant Selector

Page 26: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

DESCENDANT SELECTOR

All the paragraphs that are descendant of a div element are shown in blue

A CSS descendent selector allows you to select and style all elements that are descendants of a specified element.

div p {color: blue}

Syntax selector1 selector2 {style properties}

Page 27: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

DESCENDANT SELECTOR

<div>      <p>Web  design  rocks!</p>  </div>  <p>Hello  world.</p>

HTML CSS

div  p  {color:  blue}

Browser

Web design rocks! Hello world.

Page 28: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

SELECTOR TYPES

Element Selector

Descendant Selector

Child Selector

Id Selector

Class Selector

Element Specific Selector

General Sibling Selector

Adjacent Sibling Selector

Attribute Selector

Pseudo-class Selector

Dynamic Pseudo-class Selector

Structural Pseudo-class Selector

Nth-child Selector

Universal Selector

Child Selector

Page 29: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

CHILD SELECTOR

Only the strong elements that are direct descendants of a paragraph are shown in blue

A CSS child selector allows you to select and style only the elements that are direct descendants.

p>strong {color: blue}

Syntax selector1 > selector2 {style properties}

Page 30: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

CHILD SELECTOR

<p><strong>Web  design  rocks!</strong></p>  <p>      <a  href=“#”><strong>Hello  world.</strong></a>  </p>

HTML CSS

p>strong  {color:  blue}

Browser

Web design rocks! Hello world.

Page 31: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

SELECTOR TYPES

Element Selector

Descendant Selector

Child Selector

Id Selector

Class Selector

Element Specific Selector

General Sibling Selector

Adjacent Sibling Selector

Attribute Selector

Pseudo-class Selector

Dynamic Pseudo-class Selector

Structural Pseudo-class Selector

Nth-child Selector

Universal Selector

Id Selector

Page 32: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

ID SELECTOR

Only the element with the “nav” id is shown in blue

A CSS id selector allows you to select and style the element with the specified id.

#nav {color: blue}

Syntax #id_value {style properties}

Page 33: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

ID SELECTOR

<p  id=“nav”>Web  design  rocks!</p>  <p>Hello  world.</p>

HTML CSS

#nav  {color:  blue}

Browser

Web design rocks! Hello world.

Page 34: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

SELECTOR TYPES

Element Selector

Descendant Selector

Child Selector

Id Selector

Class Selector

Element Specific Selector

General Sibling Selector

Adjacent Sibling Selector

Attribute Selector

Pseudo-class Selector

Dynamic Pseudo-class Selector

Structural Pseudo-class Selector

Nth-child Selector

Universal Selector

Class Selector

Page 35: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

CLASS SELECTOR

Only the elements with the “ready” class are shown in blue

A CSS class selector allows you to select and style the elements with the specified class.

.ready {color: blue}

Syntax .classname {style properties}

Page 36: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

CLASS SELECTOR

<div  class=“ready”>Web  design  rocks!</div>  <p  class=“ready”>More  content.</p>  <p>      <strong  class=“ready”>Hello  world.</strong>  </p>

HTML CSS

.ready  {color:  blue}

Browser

Web design rocks! More content. Hello world.

Page 37: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

SELECTOR TYPES

Element Selector

Descendant Selector

Child Selector

Id Selector

Class Selector

Element Specific Selector

General Sibling Selector

Adjacent Sibling Selector

Attribute Selector

Pseudo-class Selector

Dynamic Pseudo-class Selector

Structural Pseudo-class Selector

Nth-child Selector

Universal Selector

Element Specific Selector

Page 38: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

ELEMENT SPECIFIC SELECTOR

Only the paragraphs with the “ready” class are shown in blue

A CSS element specific selector allows you to select and style only the elements associated with a specific class/id.

p.ready {color: blue}

Syntax element.classname {style properties}

Page 39: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

ELEMENT SPECIFIC SELECTOR

<div  class=“ready”>Web  design  rocks!</div>  <p  class=“ready”>Hello  world.</p>  <p>      <strong  class=“ready”>More  content.</strong>  </p>

HTML CSS

p.ready  {color:  blue}

Browser

Web design rocks! Hello world. More content.

Page 40: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

SELECTOR TYPES

Element Selector

Descendant Selector

Child Selector

Id Selector

Class Selector

Element Specific Selector

General Sibling Selector

Adjacent Sibling Selector

Attribute Selector

Pseudo-class Selector

Dynamic Pseudo-class Selector

Structural Pseudo-class Selector

Nth-child Selector

Universal SelectorGeneral Sibling Selector

Page 41: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

GENERAL SIBLING SELECTOR

Only the paragraphs that are siblings of a h1 are shown in blue

A CSS general sibling selector allows you to select and style the elements that are siblings of a given element.

h1~p {color: blue}

Syntax element ~ element {style properties}

Page 42: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

GENERAL SIBLING SELECTOR

<p>Web  design  rocks!</p>  <h1>Hello  world.</h1>  <p>More  content.</p>  <p>More  content.</p>

HTML CSS

h1~p  {color:  blue}

Browser

Web design rocks! Hello world. More content. More content.

Page 43: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

SELECTOR TYPES

Element Selector

Descendant Selector

Child Selector

Id Selector

Class Selector

Element Specific Selector

General Sibling Selector

Adjacent Sibling Selector

Attribute Selector

Pseudo-class Selector

Dynamic Pseudo-class Selector

Structural Pseudo-class Selector

Nth-child Selector

Universal Selector

Adjacent Sibling Selector

Page 44: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

ADJACENT SIBLING SELECTOR

Only the paragraphs that immediately follows a h1 are shown in blue.

A CSS adjacent sibling selector allows you to select and style the element that is an immediate sibling.

h1+p {color: blue}

Syntax former_element + target_element {style properties}

Page 45: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

ADJACENT SIBLING SELECTOR

<p>Web  design  rocks!</p>  <h1>Hello  world.</h1>  <p>More  content.</p>  <p>More  content.</p>

HTML CSS

h1+p  {color:  blue}

Browser

Web design rocks! Hello world. More content. More content.

Page 46: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

SELECTOR TYPES

Element Selector

Descendant Selector

Child Selector

Id Selector

Class Selector

Element Specific Selector

General Sibling Selector

Adjacent Sibling Selector

Attribute Selector

Pseudo-class Selector

Dynamic Pseudo-class Selector

Structural Pseudo-class Selector

Nth-child Selector

Universal Selector

Attribute Selector

Page 47: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

ATTRIBUTE SELECTORA CSS attribute selector allows you to select and style an element with a specific attribute or attribute value.

p[lang] {color: blue}

Syntax element[attr] {style properties}

Only the paragraphs with the lang attribute are shown in blue.

Page 48: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

Web design rocks! More content. Contact About us

ATTRIBUTE SELECTOR

<p  lang=“en”>Web  design  rocks!</p>  <p>More  content.</p>  <a  href=“#”  target=“_blank”>Contact</a>  <a  href=“#”>About  us</a>

HTML CSS

p[lang]  {color:  blue}  a[target]  {color:  red}

Browser

The a element is shown in blue by default

Page 49: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

ATTRIBUTE SELECTOR

<p  lang=“en”>Web  design  rocks!</p>  <p  lang=“fr”>Bonjour!</p>  <a  href=“contact.html”>Contact</a>  <a  href=“#”>About  us</a>

HTML CSS

p[lang=“en”]  {color:  blue}  a[href=“contact.html”]  {color:  red}

Browser

Web design rocks! Bonjour! Contact About us The a element is shown in blue by default

Page 50: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

ATTRIBUTE SELECTOR

<p  lang=“en-­‐gb  en-­‐us  en-­‐au  en-­‐nz”>  Web  design  rocks!</p>

HTML CSS

p[lang~="en-­‐us"]  {color:  blue}

Browser

Web design rocks!

Page 51: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

ATTRIBUTE SELECTOR

<p  lang=“en-­‐gb”>Web  design  rocks!</p>  <p  lang=“en-­‐us”>Hello  world.</p>  <p  lang=“en-­‐au”>More  content.</p>

HTML CSS

p[lang|="en"]  {color:  blue}

Browser

Web design rocks! Hello world. More content.

Page 52: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

SELECTOR TYPES

Element Selector

Descendant Selector

Child Selector

Id Selector

Class Selector

Element Specific Selector

General Sibling Selector

Adjacent Sibling Selector

Attribute Selector

Pseudo-class Selector

Dynamic Pseudo-class Selector

Structural Pseudo-class Selector

Nth-child Selector

Universal Selector

Pseudo-class Selector

Page 53: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

PSEUDO-CLASS SELECTOR

Links are shown in blue when their state is hover (mouse over them)

A CSS pseudo-class selector allows you to select and style an element with a special state specified by a keyword.

a:hover {color: blue}

Syntax selector:pseudo-class {style properties}

Page 54: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

PSEUDO-CLASS SELECTOR

<a  href=“#”>Contact</a>

HTML CSS

a:hover  {color:  red}

Browser

Contact

The mouse is over a link but not clicking it

Page 55: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

SELECTOR TYPES

Element Selector

Descendant Selector

Child Selector

Id Selector

Class Selector

Element Specific Selector

General Sibling Selector

Adjacent Sibling Selector

Attribute Selector

Pseudo-class Selector

Dynamic Pseudo-class Selector

Structural Pseudo-class Selector

Nth-child Selector

Universal Selector

Dynamic Pseudo-class Selector

Page 56: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

NOTICE

Coming soon.

Page 57: Learn CSS3 for beginners at rocket speed

inarocket.com - Learn CSS at rocket speed

NOTICE

Sorry for the inconvenience.

This presentation is a work in progress.

Page 58: Learn CSS3 for beginners at rocket speed

Learn front-end development at rocket speed

inarocket.com