adding more cowbell to your site with css

64
Adding More Cowbell to your Site with CSS Rob Porter - Penn State - TLT Studio @robzonenet Examples from the talk: https://dl.dropboxusercontent.com/u/7733060/cowbell-talk/index.html

Upload: amma

Post on 24-Feb-2016

27 views

Category:

Documents


0 download

DESCRIPTION

Adding More Cowbell to your Site with CSS. Rob Porter - Penn State - TLT Studio @robzonenet Examples from the talk: https://dl.dropboxusercontent.com/u/7733060/cowbell-talk/index.html. CSS. CSS is Awesome. CSS is Awesome. http://www.zazzle.com/css_is_awesome_coffee_mug-168716435071981928. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Adding More Cowbell to your Site with CSS

Adding More Cowbell to your Site with CSS

Rob Porter - Penn State - TLT Studio@robzonenet

Examples from the talk: https://dl.dropboxusercontent.com/u/7733060/cowbell-talk/index.html

Page 2: Adding More Cowbell to your Site with CSS

CSS

Page 3: Adding More Cowbell to your Site with CSS

CSS is Awesome

Page 4: Adding More Cowbell to your Site with CSS

CSS is Awesome

http://www.zazzle.com/css_is_awesome_coffee_mug-168716435071981928

Page 5: Adding More Cowbell to your Site with CSS

http://inspectelement.com/wp-content/uploads/2013/03/Q3cUg29.gif

Page 6: Adding More Cowbell to your Site with CSS

http://f3nation.com/wp-content/uploads/2013/01/Walken.jpg

Page 7: Adding More Cowbell to your Site with CSS

Substring Matching Attribute Selectors

Attribute selectors let you target an element based on its attributes.

Page 8: Adding More Cowbell to your Site with CSS

Substring Matching Attribute Selectors

[att=value] exact value

[att~=value] whitespace separated list of words

[att|=value] starts with and is immediately followed by -

[att^=value] starts with

[att$=value] ends with

[att*=value] contains

Page 9: Adding More Cowbell to your Site with CSS

Substring Matching Attribute Selectors

[att=value] “exact value” example

input[type="text"] { width: 200px;

}

Page 10: Adding More Cowbell to your Site with CSS

Substring Matching Attribute Selectors

[att$=value] “ends with” example

a[href$=".png"] { background: url(mypngicon.gif) no-repeat left 50%;

padding: 2px 0 2px 20px; }

Page 11: Adding More Cowbell to your Site with CSS

Substring Matching Attribute Selectors

[att*=value] “contains” example

ul li a[href*="google.com"] { background-image: url(demo-images/google.png);

}

Page 12: Adding More Cowbell to your Site with CSS

Pseudo-elements

Page 13: Adding More Cowbell to your Site with CSS

Pseudo-elements::first-letter

::first-line

::before

::after

Page 14: Adding More Cowbell to your Site with CSS
Page 15: Adding More Cowbell to your Site with CSS

Pseudo-elements ::before, ::after

Adding Content to your site

CSS.email-address::before {

content: "Email address: ";}

HTML<ul>

<li class="email-address">[email protected]</li></ul>

• Email address: [email protected]

Page 16: Adding More Cowbell to your Site with CSS

Pseudo-elements ::before, ::afterAdding Content to your site

CSS@media print {

#content a::after { content: " (" attr(href) ") ";

}}

HTML<a href=“http://studio.tlt.psu.edu/“>TLT STUDIO</a> is great

Printed PaperTLT STUDIO (http://studio.tlt.psu.edu) is great

Page 17: Adding More Cowbell to your Site with CSS

Child Selectors

ul > li { margin: 0 0 5px 0; }

Page 18: Adding More Cowbell to your Site with CSS

Child Selectors

ul > li { margin: 0 0 5px 0; }

ul li { margin: 0 0 5px 0; }

Page 19: Adding More Cowbell to your Site with CSS

Child Selectors

ul > li { margin: 0 0 5px 0; } Descendants

ul li { margin: 0 0 5px 0; } Children

Page 20: Adding More Cowbell to your Site with CSS

Child SelectorsHTML<ul>

<li>List item one</li><li>List item two

<ol><li>Nested list item

one</li><li>Nested list item

two</li></ol></li>

<li>List item three</li></ul>

CSSChildrenul li {

color: red; }

Descendantsul > li {

color: yellow; }

Page 21: Adding More Cowbell to your Site with CSS

Child SelectorsHTML<ul>

<li>List item one</li><li>List item two

<ol><li>Nested list item

one</li><li>Nested list item

two</li></ol></li>

<li>List item three</li></ul>

CSSChildrenul li {

color: red; }

Descendantsul > li {

color: yellow; }

Page 22: Adding More Cowbell to your Site with CSS

Child SelectorsHTML<ul>

<li>List item one</li><li>List item two

<ol><li>Nested list item

one</li><li>Nested list item

two</li></ol></li>

<li>List item three</li></ul>

CSSChildrenul li {

color: red; }

Descendantsul > li {

color: yellow; }

Page 23: Adding More Cowbell to your Site with CSS

Adjacent Sibling Combinators

p + p {color: red;

}

Page 24: Adding More Cowbell to your Site with CSS

Adjacent Sibling CombinatorsHTML

<div><p>Line One</p><p>Line Two</p><div>Box</div>

<p>Line Three</p>

</div>

CSSp + p {color: red;

}

div + p {color: yellow;

}

Page 25: Adding More Cowbell to your Site with CSS

Adjacent Sibling CombinatorsHTML

<div><p>Line One</p>

<p>Line Two</p>

<div>Box</div><p>Line

Three</p></div>

CSSp + p {color: red;

}

div + p {color: yellow;

}

Page 26: Adding More Cowbell to your Site with CSS

Adjacent Sibling CombinatorsHTML

<div><p>Line One</p><p>Line Two</p><div>Box</div>

<p>Line Three</p>

</div>

CSSp + p {color: red;

}

div + p {color: yellow;

}

Page 27: Adding More Cowbell to your Site with CSS

General Sibling Combinators

p ~ p {color: red;

}

Page 28: Adding More Cowbell to your Site with CSS

General Sibling CombinatorsHTML

<div><p>Line One</p><p>Line Two</p><div>Box</div>

<p>Line Three</p>

</div>

CSSp ~ p {color: red;

}

div ~ p {color: yellow;

}

Page 29: Adding More Cowbell to your Site with CSS

General Sibling CombinatorsHTML

<div><p>Line One</p><p>Line Two</p><div>Box</div>

<p>Line Three</p>

</div>

CSSp ~ p {color: red;

}

div ~ p {color: yellow;

}

Page 30: Adding More Cowbell to your Site with CSS

General Sibling CombinatorsHTML

<div><p>Line One</p><p>Line Two</p><div>Box</div>

<p>Line Three</p>

</div>

CSSp ~ p {color: red;

}

div ~ p {color: yellow;

}

Page 31: Adding More Cowbell to your Site with CSS

Pseudo-classes:link

:visited

:hover

:active

Page 32: Adding More Cowbell to your Site with CSS

Pseudo-classes:first-child

:last-child

:nth-child(N)

:nth-of-type(N)

:first-of-type

:last-of-type

Page 33: Adding More Cowbell to your Site with CSS

Pseudo-classes:first-child HTML<div>

<p>Line One</p><p>Line Two</p><p>Line

Three</p><div>**Box**</

div><p>Line Four</p><p>Line Five</p></div>

CSSp:first-child {

color: red;}

Page 34: Adding More Cowbell to your Site with CSS

Pseudo-classes:first-child HTML<div>

<h2>H2</h2><p>Line One</p><p>Line Two</p><p>Line

Three</p><div>**Box**</

div><p>Line Four</p><p>Line Five</p></div>

CSSp:first-child {

color: red;}

Page 35: Adding More Cowbell to your Site with CSS

Pseudo-classes:nth-child(N) HTML

<div><p>Line One</p><p>Line Two</p>

<p>Line Three</p>

<div>**Box**</div>

<p>Line Four</p><p>Line Five</p>

</div>

CSSp:nth-child(3) {

color: red;}

Page 36: Adding More Cowbell to your Site with CSS

Pseudo-classes:nth-child(N) HTML

<div><p>Line One</p><p>Line Two</p>

<p>Line Three</p>

<div>**Box**</div>

<p>Line Four</p><p>Line Five</p>

</div>

CSSp:nth-child(2n) {

color: red;}

Page 37: Adding More Cowbell to your Site with CSS

Pseudo-classes:nth-child(N)

HTML<div>

<p>Line One</p><p>Line Two</p><p>Line

Three</p><div>**Box**</

div><p>Line Four</p><p>Line Five</p></div>

CSSp:nth-child(2n+1) {

color: red;}

Page 38: Adding More Cowbell to your Site with CSS

Pseudo-classes:nth-child(N)

p:nth-child(An+B)

A = Cycle Size n = Counter starting at zero(A*0,

A*1, A*2,…)B = Offset value used to determine

where the iteration will begin

Page 39: Adding More Cowbell to your Site with CSS

Pseudo-classes:nth-child(N)

p:nth-child(odd)

p:nth-child(even)

Page 40: Adding More Cowbell to your Site with CSS

Pseudo-classes:nth-last-child(N)

p:nth-last-child(2n+3)

Page 41: Adding More Cowbell to your Site with CSS

Pseudo-classes:nth-of-type(N)

Page 42: Adding More Cowbell to your Site with CSS

Pseudo-classes:nth-of-type(N)

HTML<div>

<p>Line One</p><p>Line Two</p><p>Line

Three</p><div>**Box**</

div><p>Line Four</p><p>Line Five</p></div>

CSSp:nth-of-type(2n+1) {

color: red;}

Page 43: Adding More Cowbell to your Site with CSS

Math in CSS?

calc()

Page 44: Adding More Cowbell to your Site with CSS

Math in CSS?.sidebar {

width: 35%; float: left;

margin-right: 1em;}

.content { width: calc(65% - 1em);

float: right;}

Page 45: Adding More Cowbell to your Site with CSS

Math in CSS?.column-1-12 {

width: 8.333%;}

.column-2-12 { width: 16.6667%;

}.column-3-12 { width: 25%;

}

Page 46: Adding More Cowbell to your Site with CSS

Math in CSS?.column-1-12 {

width: 8.333%;}

.column-2-12 { width: 16.6667%;

}.column-3-12 { width: 25%;

}

.column-1-12 { width: calc(100% / 12);

}.column-2-12 {

width: calc(100% / 12 * 2);}

.column-3-12 { width: calc(100% / 12 * 3);

}

=>

Page 47: Adding More Cowbell to your Site with CSS
Page 48: Adding More Cowbell to your Site with CSS

Font Icons

Actually Font Characters Scales nicelyaria-hidden="true"

Page 49: Adding More Cowbell to your Site with CSS
Page 50: Adding More Cowbell to your Site with CSS

Free Font Icons

http://icomoon.io/http://fortawesome.github.io/Font-Awesome/icons/http://fontello.com/

Page 51: Adding More Cowbell to your Site with CSS
Page 52: Adding More Cowbell to your Site with CSS

Making Circles

circle: 1.) Border-radius: 50%

2.) Width, Height: should be same(square)

Page 53: Adding More Cowbell to your Site with CSS

Making Circles.column-8-12 {

    background: #006;    color: white;

    width: 300px;    height: 300px;

    -webkit-border-radius: 50px; -moz-border-radius: 50px;

border-radius: 50px;}

Page 54: Adding More Cowbell to your Site with CSS
Page 55: Adding More Cowbell to your Site with CSS

Box-Sizing

content-boxborder-box

Page 56: Adding More Cowbell to your Site with CSS

Box Sizing

textarea {     -webkit-box-sizing: border-box;      -moz-box-sizing: border-box;    

     box-sizing: border-box;      }

Page 57: Adding More Cowbell to your Site with CSS

Box Sizing

*, *::after, *::before {    box-sizing: border-box;

Page 58: Adding More Cowbell to your Site with CSS

CSS Transitions transition: padding 4s ease;

.example { padding: 1em;

transition: padding 4s ease; background-color: #006;

color: white; }

Page 59: Adding More Cowbell to your Site with CSS

CSS Transitions transition: padding 4s ease;

.example { padding: 1em;

transition: padding 4s ease; background-color: #006;

color: white; }

Page 60: Adding More Cowbell to your Site with CSS

CSS Transitions transition: padding 4s ease;

.example { padding: 1em;

transition: padding 4s ease; background-color: #006;

color: white; }

Page 61: Adding More Cowbell to your Site with CSS

CSS Transitions transition: padding 4s ease;

.example { padding: 1em;

transition: padding 4s ease; background-color: #006;

color: white; }

Page 62: Adding More Cowbell to your Site with CSS

CSS Transitions

transition: padding 4s ease;

ease linear ease-in ease-out ease-in-out step-start step-end

cubic-bezier(0, 0, 0.58, 1);

Page 63: Adding More Cowbell to your Site with CSS

CSS Transitions

.example { padding: 1em; transition: padding 4s ease; background-color: #006; color: white; }.example:hover { padding: 4em; background-color: #060;}

Page 64: Adding More Cowbell to your Site with CSS

Thank You

Any Questions?Email: [email protected]: @robzonenet