Bring your apps to life with CSS

What's for lunch?

Who am I?

What is a web app?

What is a web app?

Nature of a web app

Design Constraints

Which means…

CSS3!

Ready?

Slideshow

Slideshow - Markup

<section class="slideshow">



</section>

Slideshow - Style

.slideshow {
 /* Set the viewbox for the slideshow */
  width: 500px;
  height: 300px;
/* Make all slides position absolutely w.r.t this viewbox */
  position: relative;
}

.slideshow article {
/* Each slide is stacked on top of each other */
  position: absolute;
  top: 0; left: 0;
}

Slideshow - Animations

.cssanimations .slideshow article {
/* Hide all slides to prepare
for display with animations */
  opacity: 0;

/* Each slide animates linearly
in 12s cycles forever using fade animation  */
  animation: fade 6s linear infinite;
}

.cssanimations .slideshow article:nth-of-type(2) {
/* Delay starting animation for this slide by 2s */
  animation-delay: 2s;
}

.cssanimations .slideshow article:last-of-type {
/* Delay starting animation for this slide by 4s */
  animation-delay: 4s;
}

CSS3 Selectors

CSS3 Selectors

CSS Animations

animation: fade Animation Name 6sDuration of the animation linear Timing function to use infinite;

Browser Support

Slideshow - Animations

/* The fade animation */
@keyframes fade {
/* Fades in from 0% to 4% of animation */
    0% { opacity: 0; }
    4% { opacity: 1; }

/* From 4% to 33% keep opacity steady at 1 */
   33% { opacity: 1; }

/* Fades out in 4%(37% - 31%) of animation */
   37% { opacity: 0; }
  100% { opacity: 0; }
}

Calculations

Calculations

Basic Animation for each slide

Calculations

Basic Animation with 2 slides

Calculations

Animation with 2 slides synchronized

How to pause animations?

.cssanimations .slideshow:hover article {
  animation-play-state: paused;
  }

How about browsers without support for animations?

What to do?

Browsers without CSS animations

<nav>
  <a href="#one" title="View First Friend Update">●</a>
  <a href="#two" title="View Second Friend Update">●</a>
  <a href="#three" title="View Third Friend Update">●</a>
</nav>

Browsers without CSS animations

.slideshow nav {
/* Position above the slideshow */
  text-align: center;
  margin-top: -2em;
  font-size: 2em;
  display: block;
}

.slideshow article {
/* Prepare slides for showing when clicked */
  opacity: 0;
  transition: opacity 1s linear;
}

.slideshow article:first-of-type,
.slideshow article:target {
/* If no article element is targetted,
have first slide show, else,
show the target element */
  opacity: 1;
}

Transitions

transition: opacityCSS property to apply on 1sTime transition should takelinearEasing Function

How should it look on devices with smaller screens?

Slideshow - Different Screens?

/* Styles for smaller screens */
  .slideshow article {
    padding: 1em;
    overflow: hidden;
  }
  .slideshow img {
    float: left;
    width: 100px;
  }
@media screen and (min-width: 800px) {
/* Styles we used previously */
}

Media Queries

@media screen Type of media: tv, print, projection and combining queries, also not, only and "," (min-width: A media feature 800px Value for that media feature)

Slideshow - Smaller Screens

In Short…

Isotope: Graceful use of CSS3

Spinner

<span class="loader">loading…</span>

Spinner - CSS

.cssanimations .loader {
/* Set the size of the spinner */
width: 100px;
height: 100px;

/* We want to hide the text "loading" */
text-indent: 110px;
white-space: nowrap;
overflow: hidden;

/* There is no spinner but a circular spinner */
border-radius: 100px;

/* The Real Magic! */
background-image: radial-gradient(contain, black 0%, black 60%, transparent 62%),
                  linear-gradient(transparent 0%, indianred 90%, indianred 100%),
                  linear-gradient(0deg, indianred 0%, indianred 50%, #000 50%, indianred 100%);
}

CSS3 Backgrounds

In Photoshop language

Spinner - Animation

.loader {
  animation: spin 2s linear infinite;
}
@keyframes spin {
/* Make the element spin to 360deg */
    0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

In Short…

Other Subtle Effects

Make CSS3 Work for You

Easy Prefixed Gradient

Easy 2D Transforms

Install

sudo* gem install sass
sudo* gem install compass

* On a mac

Too Hard?

Follow the leaders

Remember

Should the design look the same in all browsers?

Thanks