Estelle Weyl | @estellevw | Github | Press → to advance, 2 for comments, 4 to read/write notes.
Slides: http://estelle.github.com/oscon2012/
Exercise Files: http://estelle.github.com/oscon2012/zip.zip
Click on the #4 to show some notes stored with local storage
Press → to advance and show next comments
Press ← to go back
Or navigation with buttons or browser history
Files are at estelle.github.com/oscon12
We don't have time to cover everything in depth, but resources are available to dive deeper
The * selector, or global selector, has no value.
* {} 0-0-0
Combinators, like ~, >, and + have no value
ul li {} 0-0-2 ul > li {} 0-0-2
:not has no value, but parameter selector does
.myClass:not(p) {} 0-1-1
Specificity is not inheritance
<link rel='stylesheet' type='text/css' media='screen' href='css/styles.css' /> <link rel='stylesheet' type='text/css' media='print' href='css/print.css' />
@media screen { p { color: blue; } } @media print { p { color: red; } }
<link media="screen" ...
<style> @import "myCSS.css"; ...
@import url(myCSS.css) screen; IE8+
@media screen {}
<?xml-stylesheet media="screen" ...
<link rel='stylesheet' media='screen and (min-width: 320px) and (max-width: 480px)'
href='css/smartphone.css' />
@media screen and (max-width: 480px){ a { transition: background-color 200ms linear 50ms; } } @media screen and (orientation: landscape) { a[href^="mailto:]:before { content: url(icons/email.gif); } }
media="only print and (color)" media="only screen and (orientation: portrait)" media="not screen and (color)" media="print, screen and (min-width: 480px)"
@media screen and (-webkit-min-device-pixel-ratio: 2) { .iphone4 { /* high DPI */} } @screen and (transform-3d) { .transforms {} }
Also works with (animation)
and (transition)
#presentation { -<prefix>-transition: all 1.5s linear; } @media only screen and (orientation: portrait) { #presentation{ background: indianred; } } @media only screen and (max-width: 480px) { #presentation { background: palegoldenrod; } }
shrink this window to see the presentation change colors
Forcing portrait mode
@media only screen and (max-device-width: 480px) and (orientation: landscape){ #containerDiv{ -webkit-transform:rotate(-90deg); -webkit-transform-origin: 160px 160px; } }
Forcing Landscape Mode
@media only screen and (max-device-width: 480px) and (orientation: portrait){ #containerDiv{ -webkit-transform:rotate(90deg) scale(1.45); -webkit-transform-origin: 230px 230px; } }
switch(window.orientation){ case 0: //handle portrait actions //document.getElementsByTagName('body')[0].className = 'portrait'; break; case -90: case 90: // handle landscape actions //document.getElementsByTagName('body')[0].className = 'landscape'; break; } //end switch
Event
onOrientationChange
<div id="presentation"> <div id="slides"> <!-- slide --> <div class="slide normal"> <header><h1>Slide Header</h1></header> <section> <pre contenteditable>some code</pre> </section> </div> </div> </div> <script src="prefixfree.js"></script> <script src="slides.js"></script>
body, #presentation { padding: 0; margin: 0; width: 100%; height: 100%; position: absolute; left: 0px; top: 0px; } #presentation { overflow: hidden; }
.slide { width: 900px; height: 700px; background-color: #efefef; }
Refresh
.slide { position: absolute; left: 50%; top: 50%;}
Refresh
.slide { margin-top: -350px; margin-left: -450px; }
Refresh
add some prettiness and refresh again
.slide { padding: 20px; } body { font-family: sans-serif; }
.slide { display: none; overflow: hidden; } .past, .current, .future { display: block; } .slide.past { margin-left: -1400px;} .slide.current { margin-left: -450px;} .slide.future { margin-left: 500px;}
The slide deck now works, but it's ugly, and the transitions suck!
You can continue with index.html, or go to index02.html
Border Properties: border-radius
.slide { border-radius: 50px; }
Can we use selectors to give different slides different corners?
.slide { border-radius: 50px 0; } .slide:nth-of-type(odd) { border-radius: 0 50px; }
#presentation { background-color: #000; }
.slide { border: 5px solid #fff; box-shadow: 0 0 20px rgba(0,0,0,0.6), inset 0 0 6px rgba(0,0,0,0.4); }
.slide { box-sizing: border-box; }
Font-size: rem units
:root { font-size: 162.5%; } h1 { font-size:1.8rem; } pre { font-size: 1.5rem; } p { font-size: 1.5rem; margin: 1rem 0 0 0; }
#presentation { background-image: linear-gradient(#b8c6df,#6d88b7); background-image: linear-gradient(to bottom, #b8c6df 0%, #6d88b7 100%); }
continue on in your current file, or go to index03.html
background-image: linear-gradient(left, rgba(0,0,0,0.2) 50%, transparent 50%), linear-gradient(left, transparent 40%, rgba(0,0,0,0.2) 40%), linear-gradient(left, transparent 60%, rgba(0,0,0,0.2) 60%), linear-gradient(left, transparent 50%, rgba(0,0,0,0.2) 50%), linear-gradient(left, transparent 40%, rgba(0,0,0,0.2) 40%), linear-gradient(left, transparent 60%, rgba(0,0,0,0.2) 60%), linear-gradient(left, transparent 50%, rgba(0,0,0,0.2) 50%), linear-gradient(left, transparent 40%, rgba(0,0,0,0.2) 40%), linear-gradient(left, transparent 60%, rgba(0,0,0,0.2) 60%), linear-gradient(left, red 14%, orange 15%, orange 28%, yellow 29%, yellow 42%, green 43%, green 56%, blue 57%, blue 70%, magenta 71%, magenta 85%, purple 86%); background-size: 1px 50%, 1px 50px, 32px, 120px, 80px, 60px, 90px, 110px, 70px, 500px; }
Transition properties
.slides {transition: 1s;}
.slide {opacity: 0.5;} .slide.far-past {margin-left: -2400px;} .slide.past {margin-left: -1400px;} .slide.current {margin-left: -450px; opacity: 1;} .slide.future {margin-left: 500px;} .slide.far-future {margin-left: 1500px;}
.slides {transition: margin-left 1s, opacity 2s;}
continue on in your current file, or go to index04.html
.slide {transform: scale(0.8); transition: margin-left 1s, transform 1s, opacity 2s;}
.slide.current {transform: scale(1);}
.slide {transition: all 1.2s linear;}