We're going to Make a Slide Deck

Because CSS is Awesome

The HTML

<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>

Give the slide deck breathing room

body,
#presentation {
  padding: 0;
  margin: 0;
  width: 100%;
  height: 100%;
  position: absolute;
  left: 0px; 
  top: 0px;
}

#presentation {
  overflow: hidden;
}

Center the slide on the page

.slide {
  width: 900px;
  height: 700px;
  background-color: #efefef; }

Refresh

.slide {
  position: absolute;
  left: 50%;
  top: 50%;}

Refresh

Center the slide on the page

.slide {
    margin-top: -350px;
    margin-left: -450px;
}

Refresh

sooooo ugly

add some prettiness and refresh again

.slide {
    padding: 20px;
} 
body {
    font-family: sans-serif;
}

Slide location (class set with JS)

.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;}

Refresh

The slide deck now works, but it's ugly, and the transitions suck!

Rounded Corners

Border Properties: border-radius

.slide {
	border-radius: 50px;
}

Can we use selectors to give different slides different corners?

Rounded corners

.slide {
	border-radius: 50px 0;
}
.slide:nth-of-type(odd) {
	border-radius: 0 50px;
}

Spiffier Borders with Shadows

#presentation {
  background-color: #000;  
}

Shadows: box-shadows

.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);
}

Box Model Gotcha!

Box Sizing

.slide {
  box-sizing: border-box;   
}

Default font sizes?

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; }

Boring Background?

Gradients

#presentation {
  background-image: 
    linear-gradient(#b8c6df,#6d88b7);
  background-image: 
    linear-gradient(to bottom, 
                    #b8c6df 0%,
                    #6d88b7 100%);
}
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;
}

Sexier slide transitions

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;}

Transforms

Transforms

.slide {transform: scale(0.8);
       transition: 
          margin-left 1s, 
          transform 1s,
          opacity 2s;}
.slide.current    {transform: scale(1);}
.slide {transition: all 1.2s linear;}