How to Create The Apple Watch Breathe App Animation with CSS

How to Create The Apple Watch Breathe App Animation with CSS

The Apple Watch comes with a stock app called Breathe that reminds you to… breathe. There’s actually more to it than that, it’s a self wellness app of sorts, that reminds you to take a brief moment out of your stressful day and focus on your breathing to encourage relaxation. Additionally, the app has a minimalistic interface with a nice animation.

I thought it would be fun (and relaxing) to recreate the design, particularly in vanilla CSS. Here’s how far I got, which feels pretty close.

 

Making the circles

First things first, we need a set of circles that make up that flower looking design. The app itself adds a circle to the layout for each minute that is added to the timer, but we’re going to stick with a static set of six for this demo. It feels like we could get tricky by using ::before and ::after to reduce the HTML markup, but we can keep it simple.

<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>

We’re going to make the full size of each circle 125px which is an arbitrary number. The important thing is that the default state of the circles should be all of them stacked on top of one another. We can use absolute positioning to do that.

.circle {
  border-radius: 50%;
  height: 125px;
  position: absolute;
  transform: translate(0, 0);
  width: 125px;
}

Note that we’re using the translate function of the transform property to center everything. I had originally tried using basic top, right, bottom, left properties but found later that animating translate is much smoother. I also originally thought that positioning the circles in the full expanded state would be the best place to start, but also found that the animations were cumbersome to create that way because it required resetting each one to center. Lessons learned!

If we were to stop here, there would be nothing on the screen and that’s because we have not set a background color. We’ll get to the nice fancy colors used in the app in a bit, but it might be helpful to add a white background for now with a hint of opacity to help see what’s happening as we work.

 

We need a container!

You may have noticed that our circles are nicely stacked, but nowhere near the actual center of the viewport. We’re going to need to wrap these bad boys in a parent element that we can use to position the entire bunch. Plus, that container will serve as the element that pulses and rotates the entire set later. That was another lesson I had to learn the hard way because I stubbornly did not want the extra markup of a container and thought I could work around it.

We’re calling the container .watch-face here and setting it to the same width and height as a single circle.

<div class="watch-face">
  <div class="circle"></div>
  <div class="circle"></div>
  <div class="circle"></div>
  <div class="circle"></div>
  <div class="circle"></div>
  <div class="circle"></div>
</div>

Now, we can add a little flex to the body element to center everything up.

body {
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
}

 

Next up, animate the circles

At this point, I was eager to see the circles positioned in that neat floral, overlapping arrangement. I knew that it would be difficult to animate the exact position of each circle without seeing them positioned first, so I overrode the transform property in each circle to see where they’d land.

We could set up a class for each circle, but using :nth-child seems easier.

.circle:nth-child(1) {
  transform: translate(-35px, -50px);
}

/* Skipping 2-5 for brevity... */

.circle:nth-child(6) {
  transform: translate(35px, 50px);
}

It took me a few swings and misses to find coordinates that worked. It ultimately depends on the size of the circles and it may take some finessing.

 

Armed with the coordinates, we can register the animations. I removed the transform coordinates that were applied to each :nth-child and moved them into keyframes:

@keyframes circle-1 {
  0% {
    transform: translate(0, 0);
  }
  100% {
    transform: translate(-35px, -50px);
  }
}

/* And so on... */

I have to admit that the way I went about it feels super clunky because each circle has it’s own animation. It would be slicker to have one animation that can rule them all to push and re-center the circles, but maybe someone else reading has an idea and can share it in the comments.

Now we can apply those animations to each :nth-child in place of transform:

.circle:nth-child(1) {
  animation: circle-1 4s ease alternate infinite;
}

/* And so on... */

Note that we set the animation-timing-function to ease because that feels smooth…at least to me! We also set the animation-direction to alternate so it plays back and forth and set the animation-iteration-count to inifinite so it stays running.

 

Color, color, color!

Oh yeah, let’s paint this in! From what I can tell, there are really only two colors in the design and the opacity is what makes it feel like more of a spectrum.

The circles on the left are a greenish color and the ones on the right are sorta blue. We can select the odd-numbered circles to apply the green and the even-numbered ones to apply the blue.

.circle:nth-child(odd) {
  background: #61bea2;
}

.circle:nth-child(even) {
  background: #529ca0;
}

Oh, and don’t forget to remove the white background from the .circle element. It won’t hurt anything, but it’s nice to clean up after ourselves. I admittedly forgot to do this on the first go.

 

It’s also at this point that others in the comments have suggested that replacing opacityfor mix-blend-mode with a value of screen makes for a nicer way to blend the colors of the circles. I’ve since updated the demos and the code.

Pulse and rotate

Remember that pesky .watch-face container we created? Well, we can animate it to pulse the circles in and out while rotating the entire bunch.

I had totally forgotten that transform functions can be chained together. That makes things a little cleaner because it allows us to apply scale() and rotate() on the same line.

@keyframes pulse {
  0% {
    transform: scale(.15) rotate(180deg);
  }
  100% {
    transform: scale(1);
  }
}

…and apply that to the .watch-face element.

.watch-face {
  height: 125px;
  width: 125px;
  animation: pulse 4s cubic-bezier(0.5, 0, 0.5, 1) alternate infinite;
}

Like the circles, we want the animation to run both ways and repeat infinitely. In this case, the scale drops to a super small size as the circles stack on top of each other and the whole thing rotates halfway on the way out before returning back on the way in.

I’ll admit that I am not a buff when it comes to finding the right animation-timing-function for the smoothest or exact animations. I played with cubic-bezier and found something I think feels pretty good, but it’s possible that a stock value like ease-in would work just as well.

All together now!

Here’s everything smushed into the same demo.

 

If you’re having a stressful day, even you don’t have an apple watch, you can gaze into the CSS animation you’ve created and lull yourself into tranquility.

Make sure you don’t keep all of this peacefulness to yourself, and pass along your newly discovered knowledge. 

For all things Apple, check out all of our latest Apple related guides.

references: apple, css tricks, codepen, mozilla

Make an Animated GIF with Photoshop – How to Guide

Make an Animated GIF with Photoshop – How to Guide

10 Easy to Follow Steps:

  1. Upload your images to Photoshop.
  2. Open up the Timeline window.
  3. In the Timeline window, click “Create Frame Animation.”
  4. Create a new layer for each new frame.
  5. Open the same menu icon on the right, and choose “Make Frames From Layers.”
  6. Under each frame, select how long it should appear for before switching to the next frame.
  7. At the bottom of the toolbar, select how many times you’d like it to loop.
  8. Preview your GIF by pressing the play icon.
  9. Save and Export Your GIF.
  10. You’ve created a GIF!

What is a GIF?

If you’ve spent any time on the internet at all, you’ve probably come in contact with an animated GIF. It’s an image file that allows you to feature animated images, which makes it seem like the image is moving. Think of them as a hybrid between a still image and a video.

Why are GIFs great additions to virtually any website? They’re easy to consume, provide a new way to capture your viewers’ attention, and can potentially create an emotional impact. And since content that makes us feel something encourages us to share, these tiny animations are worth experimenting with.

The best part about GIFs is that they aren’t too hard to make. If you have access to Photoshop and a few minutes to spare, you can create an animated GIF in no time.

If you don’t already have a copy of Photoshop, here’s the official Adobe link to buy or obtain a free trial of Adobe Photoshop CC.

In the following guide on making animated GIFs, I’m using Photoshop CC.

How to Create an Animated GIF with Photoshop

Here’s a basic example of an animated GIF you could make using this guide:

marketing-trivia-GIF-example-1.gif

Alright, let’s get started.

Step 1: Upload your images to Photoshop.

If you already have images created …

Gather the images you want in a separate folder. To upload them into Photoshop, click File > Scripts > Load Files Into Stack.

load-file-into-stack.png

Then, select Browse, and choose which files you’d like to use in your GIF. Then, click OK.

load-multiple-images.png

Photoshop will then create a separate layer for each image you’ve selected. Once you’ve done that, skip to step two.

If you don’t already have the series of images created …

Create each frame of the animated GIF as a different Photoshop layer. To add a new layer, chose Layer New Layer.

add-new-layer.png

Be sure to name your layers so you can keep track of them easily when you make your GIF. To name a layer, go to the Layer panel on the bottom right of your screen, double-click on the default layer name, and type in the name you want to change it to. Press Enter when you’re finished.

name-layers.png

Once you have your layers in there and you’ve named them all, you’re ready for step two.

Pro Tip: If you want to combine layers so they appear in a single frame in your GIF, turn visibility on for the layers you want to merge (by clicking on the “eye” to the left of each layer name so only the eyes for the layers you want to merge are open). Next, press Shift + Command + Option + E (Mac) or Shift + Ctrl + Alt + E (Windows). Photoshop will create a new layer containing the merged content, which you should also rename.

Step 2: Open up the Timeline window.

To open Timeline, go to the top navigation, choose Window > Timeline. The Timeline will let you turn different layers on and off for different periods of time, thereby turning your static image into a GIF.

open-timeline.png

The Timeline window will appear at the bottom of your screen. Here’s what it looks like:

timeline-in-photoshop.png

Step 3: In the Timeline window, click “Create Frame Animation.”

If it’s not automatically selected, choose it from the dropdown menu — but then be sure to actually click it, otherwise the frame animation options won’t show up.

create-frame-animation.png

Now, your Timeline should look something like this:

timeline-with-frame-animation.png

Step 4: Create a new layer for each new frame.

To do this, first select all your layers by going to the top navigation menu and choosing Select > All Layers.

Then, click the menu icon on the right of the Timeline screen.

timeline-icon.png

From the dropdown menu that appears, choose Create new layer for each new frame.

new-layer-for-new-frame.png

Step 5: Open the same menu icon on the right, and choose “Make Frames From Layers.”

This will make each layer a frame of your GIF.

make-frames-from-layers.png

Step 6: Under each frame, select how long it should appear for before switching to the next frame.

To do this, click the time below each frame and choose how long you’d like it to appear. In our case, we chose 0.5 seconds per frame.

choose-frame-time.png

Step 7: At the bottom of the toolbar, select how many times you’d like it to loop.

The default will say Once, but you can loop it as many times as you want, including Forever. Click Other if you’d like to specify a custom number of repetitions. 

choose-loop-number.png

Step 8: Preview your GIF by pressing the play icon.

play-icon.png

Step 9: Save and Export Your GIF

Satisfied with your GIF? Save it to use online by going to the top navigation bar and clicking File > Export > Save for Web (Legacy)…

save-for-web.png

Next, choose the type of GIF file you’d like to save it as under the Presetdropdown. If you have a GIF with gradients, choose Dithered GIFs to prevent color banding. If your image employs a lot of solid colors, you may opt for no dither. 

The number next to the GIF file determines how large (and how precise) the GIF colors will be compared to the original JPEGs or PNGs. According to Adobe, a higher dithering percentage translates to the appearance of more colors and detail — but it increases the file size. 

save-for-web-preset-dropdown.png

Click Save at the bottom to save the file to your computer. Now you’re ready to upload this GIF to use in your marketing! 

Upload the GIF file into any place online that you’d put an image, and it should play seamlessly. Here’s what the final product might look like:

marketing-trivia-GIF-example.gif

How to Use GIFs in Your Marketing

1) On social media.

Pinterest was the first to enable animated GIFs, followed by Twitter. And by the summer of 2015, Facebook had also jumped on the GIF bandwagon. Then, Instagram changed the game with Boomerang, which lets users film and share their own GIFs. On any of these social feeds, animated GIFs can be a great way to stand out in a crowded feed.

2) In your emails.

Animated GIFs display in email the same way a regular image does. So why not spruce up your emails by replacing still images with animated ones?

Not only could this help capture recipients’ attention with novelty alone, but it could also have a direct impact on your bottom line. For some brands, including an animated GIF in emails correlated with as much as a 109% increase in revenue.

Make use of GIFs by showcasing products, making event announcements, or otherwise enticing readers. Check out the GIF below from women’s clothing shop Ann Taylor LOFT: They made a present look like it’s shaking to create intrigue and get recipients to click through to “unwrap” their gift.

loft-unwrap-animation-repeat.gif

Source: Litmus

3) In blog posts.

Your blog post doesn’t have to be about animated GIFs or structured like a BuzzFeed-style listicle to include GIFs — although, we do love a good dose of silly listicle GIFs every once in a while.

references: hubspot

Now you can share this info to anyone else asking “How do make an animated GIF with Photoshop?”

Learn How to Create an Animated Sprite with Photoshop

Learn How to Create an Animated Sprite with Photoshop

What You’ll Be Creating

In this guide, I will show you how to create an animated sprite with Photoshop, using just a few simple tools. In the process, I will cover all of the basic rules that you can apply to your future pixel art illustrations.

If you do not have a copy of Adobe Photoshop, I would recommend signing up for Adobe Photoshop CC (Creative Cloud).

Here’s the official link:
Adobe Photoshop CC

Select the Pencil Tool from the Toolbar, it will be your primary instrument for this guide. Select a Hard Round brush in the Brush settings and apply the settings shown below. Your aim is to make the line absolutely sharp.

Brush Settings

Set up Pencil Mode for the Eraser Tool and use the same brush settings as below.

Turn on the Pixel Grid (View > Show > Pixel Grid). If you don’t see this item in the menu, go to Preferences > Performance and turn on the graphic acceleration.

Note: The grid will be seen only on a newly created canvas with zoom level 600%and above.

Show Pixel Grid
Use Graphic Acceleration

Go to Preferences > General (Control-K) and set up Image Interpolation to Nearest Neighbor. This will ensure that the edges of the objects you work with always stay sharp.

Preferences - General

Go to Preferences > Units & Rulers and choose Pixels in the drop-down menu near Rulers to see all measurements in pixels.

Preferences - Units  Rulers

Now that everything is set up, we can start creating the sprite.

Make a sketch of a character with a distinct silhouette, and try not to overload it with many details. It’s not important to paint the colors, the outline should be enough, as long as you understand how your character should look. I prepared a sketch of a space trooper for this guide.

Sketch

Press Control-T or use Edit > Free Transform to scale down your character to 60px in height.

The size of the object is shown in the Info panel. Notice the Interpolation setting, it should be the same as we set in Step 4. In this case, it’s not that important, as we are only turning a sketch into pixel art, but pay attention to that feature in future when you work with pixelated objects.

Scale Down Character

Zoom in to the image by 300-400% to make it easier to render. Reduce the opacity of your sketch.

Create a new layer (Layer > New > Layer) and draw an outline of your character with the Pencil Tool.

If your character is symmetrical, like mine is, just create one half, duplicate it, and flip it horizontally (Edit > Transform > Flip Horizontal).

Outline Process

Rule of the Rhythm: Try to split complex shapes into simple elements. When pixels in the line form a “rhythm” like 1-2-3 and 1-1-2-2-3-3 the outline looks much better to the human eye than a randomly drawn line. However this rule can be broken if the shape requires it.

Rule of the Rhythm
Two rhythmic and one randomly drawn line.

When the outline is ready, choose main colors and paint large shapes. Do it on a separate layer beneath the one with the outline.

Painting Large Shapes

Smooth the inner side of the outline by adding shades of the color.

Adding Shades

Keep adding more shades. As you can see, I corrected some shapes and details along the way.

Adding Shades Process

Create a new layer to add the highlight.

Choose Overlay from the drop down menu on the Layer panel. Paint with a light color over the areas you want to highlight. Smooth the shape of highlighted area by choosing Filter > Blur > Blur.

Adding Highlight

I flipped the painted half horizontally, added final color touches here and there, and merged the layers.

Final Touches

The character now lacks contrast. Use Levels (Image > Adjustments > Levels) first and then change the tone or halftone with Color Balance (Image > Adjustments > Color Balance) to make warmer and cooler versions.

Tuning With Levels and Color Balance

I decided to go with the third version. Now let’s move on to the animation process.

Final Character
Final character with 400% zoom.

Create a copy of the layer (Layer > New > Layer Via Copy) and move it 1 pixel up and 2 pixels right selecting Move Tool (V) and using your arrow keys. This is the key phase for animating the running character.

Change the original layer’s Opacity to 50% to see previous frame of animation. This is called “Onion Skinning.”

Creating Next Frame

Now bend the character’s legs and arms as if it is running.

  • Select the left arm using Lasso Tool
  • Using Free Transform Tool (Edit > Free Transform) and holding Control move the container markers to lead the arm behind the back
  • Select the shank of the right leg and move it down as on the first frame – we need that leg stretched.
  • Select the left leg and move it up – this leg bends up
  • Using Pencil and Eraser Tools, redraw all the elbow parts of the right arm.
Creating Running Phase

Now you will need to redraw the new position of the legs and arms as I explained inSection 2 of this guide. This is because transforming the legs and arms will distort the pixels, and the shape will no longer be clean.

Finalizing Running Phase

Make the copy of the second layer and flip it horizontally. And now you have one idle position and two running phases. Select each layer and restore its Opacity to 100%.

Flipping Running Phase

Go to Window > Timeline to show Timeline panel and press Create Frame Animation.

Create Frame Animation

In the Timeline panel, perform the following steps:

  1. Choose Frame Delay time 0.15 sec
  2. Click on Duplicates Selected Frames button to add 3 more copies
  3. Change looping options to Forever
Duplicate Frames

To choose the proper layer for each animation frame, click on the Eye icon near the layer name in the Layer panel.

  • 1st frame: choose idle position
  • 2nd frame: choose the second layer
  • 3rd frame: choose idle position once again
  • 4th frame: choose the third layer
Choose Proper Layer For Each Frame

Press Space button to play the animation.

Final Animation Preview
Final animation with 100% zoom.

Now save your result. Go to File > Save For Web and select GIF format. Scale image size to 300% for better presentation and press Save.

Save For Web Settings

In this guide, I showed you how to draw and animate a pixel art character in Photoshop. In the process, you learned how to set up your canvas and tools, how to draw your character using the Pencil Tool, as well as how to animate your character using Photoshop‘s Timeline feature. I hope that you learned something from this guide and can use these techniques to create some pixel art of your own.

Final Animation

references: tutsplus

I’ve listed some related items that may be of interest to you:

CSS Transitions and Animations: Intro Guide

CSS Transitions and Animations: Intro Guide

I’ve noticed in the comments of other posts recently that some readers would like more “tips and tricks” articles, particularly about CSS. So in today’s post, I’ll be providing what I hope is a useful introduction to a bit of CSS “trickery” that can be used to create compelling microinteractions across your website. Specifically, we’ll be learning how to create CSS transitions and animations. We’ll also be talking about when and where you might want to use them.

What Are CSS Transitions and Animations?

The evolution of CSS over the years has lead to some really amazing innovations within the language. In the case of transitions and animations, what previously required a program like Adobe Flash or another coding language altogether (such as Javascript) is now possible with nothing but HTML and CSS.

This kind of language maturity, enabled by better browsers and higher web standards (among other things), has been a huge boon to web designers who double as front end developers. They can now do more with less and the whole process of web design/development has become a bit easier.

Nevertheless, CSS transitions and animations are still considered advanced uses of CSS. A spectrum of coding I try to stay away from in most of my articles since I do not consider myself an “advanced developer”–even in language as accessible as HTML or CSS.

That said though, after reading up on W3Schools and elsewhere I think a sufficiently simple introduction to these concepts is within the grasp of not only myself but a good deal of the WTG readership as well.

To begin, I think we need to have a really good idea of what, exactly, CSS transitions and animations are before jumping into examples and code.

CSS Transitions

A CSS transition allows you to change the property values of an element over a given duration that you set. To create a transition you must first identify which CSS property you want to add an effect to and then specify the duration of the effect. If no duration is set, the transition will not occur.

There are four transition properties:

transition-delay – specifies the delay, in seconds (s), you would like to assign your transition effect.

transition-duration – specifies the duration, in seconds (s) or milliseconds (ms), you would like to assign your transition effect.

transition-property – specifies the name of the CSS property your transition effect is meant for.

transition-timing-function – Specifies the speed curve of the transition effect. Meaning, the type of speed variation you want to select for your transition effect. There is no “fast” or “slow” options. Instead there are speed curve options that go from one speed to another. Such as “ease” which tells your effect to start slow, then go fast, then end slowly.

To create a transition you only need to change one of these properties over the duration you choose. However, it is possible to change more than one property at the same time; resulting in more dramatic transitions.

CSS Animations

Where CSS transitions are all about altering element properties as they move from state to state, CSS animations are dependent on keyframes and animation properties.

keyframes – keyframes are used to define the styles an element will have at various times.

animation properties – animation properties are used to assign @keyframes to a specific element and determine how it is animated.

There are eight animation properties:

animation-delay – specifies a delay for the start of an animation.

animation-direction – specifies whether an animation should play in reverse direction or alternate cycles.

animation-duration – specifies how many seconds or milliseconds an animation takes to complete one cycle.

animation-fill-mode – specifies a style for the element when the animation is not playing. Such as when it is finished or when it has a delay.

animation-iteration-count – specifies the number of times an animation should be played.

animation-name – specifies the name of the @keyframes animation.

animation-play-state – specifies whether the animation is running or paused.

animation-timing-function – specifies the speed curve of the animation.

The examples below will show you how these things are used together in various ways. Once you understand the relationships between them you’ll be able to figure out all kinds of interesting ways to use them.

A Quick Note on Vendor Prefixes

In your personal usage of CSS transitions and animations you will most likely need to use vendor prefixes. In some of the code below you will no doubt notice some vendor prefixes. Many of the source examples do not contain vendor prefixes, so if you want to see what the code looks like without them you can check there; I thought it might be helpful to provide a fuller picture.

For the uninitiated, when I say “vendor prefix” I’m referring to a prefix that needs to be added to your CSS based on the range of browsers you want to support your transitions and animations.

A good resource for identifying the necessary prefixes for each browser is caniuse.com. You can also check out the respective pages for transitions and animations on W3Schools. Or, if you’d like to avoid the mess of prefixes altogether, you can use a tool like Bourbon.io.

CSS Transition Examples

The CSS transition examples below are all transitions I’ve found from various sources that show what’s possible with these relatively new CSS capabilities. I’ve chosen to recreate the examples I found using CodePen so you can easily take a peak at the HTML and CSS required for each example while also seeing it in action
1. Linear

Example via.

2. Spin

Example via.

3. Color

Example via.

4. Square to Circle

Example via.

5. Card

Example via.

CSS Animation Examples

Again, the CSS animation examples below are from various sources around the web. Just as above, the CodePen allows you to see the animation and the required code in one place. You can also follow my source links to get more information (in some cases) on each example.
1. Pulse

Example via.

2. Shake

Example via.

3. Bouncing

Example via.

4. Bounce In

Example via.

5. Linear Bar

Example via.

Potential Use Cases for CSS Transitions & Animations

As I mentioned above, CSS transitions and animations are ideal for creating compelling and delightful microinteractions across your website. A lot of great WordPress themes and plugins come with some of these behaviors in place. A good example being the Divi Builder, which allows you to control transitions and animations within its module controls.

You may however wish to take the basics above and apply them other areas of your site in which a theme or plugin author has not given you easy control over. The following ideas might help you get started.

  • An email opt-in form that makes a delightful entrance and exist; such as bouncing in and folding closed to disappear.
  • A form that shakes when the essential information is not and someone attempt to submit it as finished.
  • Buttons that fold open, bounce, shake, or in some other way respond to hovering and clicking.
  • Preview images that turn over to reveal more information.
  • Subtle background graphics that move, creating depth.
  • Beautiful charts that spring into action as they load.
  • Google Doodle style experiments, logos, and more.
  • Games (for the really ambitious).
  • Ads that you can interact with or that subtly change shape to draw attention.
  • Beautiful product displays that rotate and respond to the mouse.
  • Beautiful stat counters.
  • And whatever else your imagination can think up.

Inspiring Showcases of CSS Transitions and Animations

If you need more visual stimulus than a list of ideas, I’ve take the liberty of compiling a small but impressive showcase of inspiring CSS transitions and animations that I hope will show off the potential illustrated in the rather basic examples I created above.

Logos in Pure CSS

Logos-In-Pure-CSS

Logos in Pure CSS is a great showcase of world famous logos re-created with nothing but CSS. In their current form they use animations and transitions to show how they are made and how they stack up against their traditional counterparts. However, I think it’s important to note that just creating your logo in HTML/CSS opens up a lot of interesting possibilities.

Go to Logos in Pure CSS

CSS A/Z

CSS-A-Z

CSS A/Z is a showcase of HTML/CSS animated sketches; one for each letter of the alphabet. Great stuff and a lot of ideas for sprucing up seemingly insignificant elements on your website.

Go to CSS A/Z

Double Ring

Double-ring

I think Double Ring is a great example of something you could do with a logo to make it more eye catching and interesting.

Go to Double Ring

Navigation Bar

nav-bar

Navigation Bar is an example of just how dynamic and beautiful something as standard as navigation can become when given some advanced CSS love.

Go to Navigation Bar

In Pieces

In-Pieces

In Pieces is a magnificent (and highly complex) use case of CSS animation. It’s an interactive exhibition of the evolution of 30 species of animals. Truly breathtaking and a great indicator of just how powerful a tool CSS can be.

Go to In Pieces

Additional Resources & Tutorials

In your quest to master CSS transitions and animations, there is a good chance that you’ll need or want more detail than I am able to provide in this post. Additionally, someone else’s writing style may be a bette fit for the way you think. That’s why I’ve compiled a short list of other useful resources and tutorials below for you to take advantage of.

In Conclusion

CSS transitions and animations are an extremely useful and versatile set of capabilities. You can do small subtle things or big in-your-face impressive things. But either way, it all starts with mastering the basics and moving on from there.

I hope this post is a welcome change of pace for those who have been requesting more CSS related content. If you have any more thoughts or requests on this post or future posts then please feel free to drop us a line in the comments section below.

references: elegant themes, w3schools, shayhowe, caniuse, bourbon

Learn How to Create 5 Incredible CSS Animations

Learn How to Create 5 Incredible CSS Animations

You’ve probably noticed that more and more CSS animation examples have been appearing on websites lately. Web designers are getting creative and using CSS animations to bring personality to their sites, capture complex ideas effortlessly, and subtly guide their users’ actions.

The golden rule here is that your CSS animations shouldn’t be overblown – even a subtle movement can have a big impact. The best animations you see online still can have their roots in Disney’s classic 12 principles of animation. 

Here, I’ve pulled together a selection of some interesting CSS animation examples from websites around the world, and dug into the code to show you how to achieve these effects yourself.

What is a CSS animation?

CSS animation is a method of animating certain HTML elements without having to use processor and memory-hungry JavaScript or Flash. There’s no limit to the number or frequency of CSS properties that can be changed. CSS animations are initiated by specifying keyframes for the animation: these keyframes contain the styles that the element will have.

1. Rising Bubbles

The CSS bubble animation that features on 7UP is a beautiful example of carrying a brand theme through into the website design. The animation consists of a few elements: the SVG ‘drawing’ of the bubbles and then two animations applied to each bubble. 

The first animation changes the opacity of the bubble and moves it vertically in the view box; the second creates the wobbling effect for added realism. The offsets are handled by targeting each bubble and applying a different animation duration and delay.

In order to create our bubbles we’ll be using SVG. In our SVG we create two layers of bubbles: one for the larger bubbles and one for the smaller bubbles. Inside the SVG we position all of our bubbles at the bottom of the view box.

<g class="bubbles-large" stroke-width="7">
  <g transform="translate(10 940)">
  <circle cx="35" cy="35" r="35"/>
  </g>
  ...
</g>
<g class="bubbles-small" stroke-width="4">
  <g transform="translate(147 984)">
  <circle cx="15" cy="15" r="15"/>
  </g>
</g>
  ...
</g>

In order to apply two separate animations to our SVGs, both utilising the transform property, we need to apply the animations to separate elements. The <g> element in SVG can be used much like a div in HTML; we need to wrap each of our bubbles (which are already in a group) in a group tag.

<g>
  <g transform="translate(10 940)">
  <circle cx="35" cy="35" r="35"/>
  </g>
</g>

CSS has a powerful animation engine and really simple code in order to produce complex animations. We’ll start with moving the bubbles up the screen and changing their opacity in order to fade them in and out at the beginning and end of the animation.

@keyframes up {
  0% {
  opacity: 0;
  }
  10%, 90% {
  opacity: 1;
  }
  100% {
  opacity: 0;
  transform: translateY(-1024px);
  }
}

In order to create a wobbling effect, we simply need to move (or translate) the bubble left and right, by just the right amount – too much will cause the animation to look too jaunting and disconnected, while too little will go mostly unnoticed. Experimentation is key with when working with animation.

@keyframes wobble {
  33% {
  transform: translateX(-50px);
  }
  66% {
  transform: translateX(50px);
  } }

In order to apply the animation to our bubbles, we’ll be using the groups we used earlier and the help of nth-of-type to identify each bubble group individually. We start by applying an opacity value to the bubbles and the will-change property in order to utilise hardware acceleration.

.bubbles-large > g {
  opacity: 0;
will-change: transform, opacity;}
.bubbles-large g:nth-of-type(1) {...}
...
.bubbles-small g:nth-of-type(10) {...}

We want to keep all the animation times and delays within a couple of seconds of each other and set them to repeat infinitely. Lastly, we apply the ease-in-outtiming function to our wobble animation to make it look a little more natural.

.bubbles-large g:nth-of-type(1) {
  animation: up 6.5s infinite; }
.bubbles-large g:nth-of-type(1) circle {
  animation: wobble 3s infinite ease-in-out; }
...
bubbles-small g:nth-of-type(9) circle {
  animation: wobble 3s 275ms infinite ease-in-out; }
.bubbles-small g:nth-of-type(10) {
animation: up 6s 900ms infinite;}

2. Scrolling Mouse

A subtle scrolling mouse animation can give direction to the user when they first land on a website. Although this can be accomplished using HTML elements and properties, we’re going to use SVG as this is more suited to drawing.

Inside our SVG we need a rectangle with rounded corners and a circle for the element we’re going to animate, by using SVG we can scale the icon to any size we need.

<svg class="mouse" xmlns="..." viewBox="0 0 76 130" preserveAspectRatio="xMidYmid meet">
  <g fill="none" fill-rule="evenodd">
  <rect width="70" height="118" x="1.5" y="1.5" stroke="#FFF" stroke-width="3" rx="36"/>
  <circle cx="36.5" cy="31.5" r="4.5" fill="#FFF"/>
  </g>
</svg>

Now we’ve created our SVG, we need to apply some simple styles in order to control the size and position of the icon within our container. We’ve wrapped a link around the mouse SVG and positioned it to the bottom of the screen.

.scroll-link {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
}
.mouse {
  max-width: 2.5rem;
  width: 100%;
  height: auto;
}

Next we’ll create our animation. At 0 and 20 per cent of the way through our animation, we want to set the state of our element as it begins. By setting it to 20% of the way through, it will stay still for part of the time when repeated infinitely.

@keyframes scroll {
  0%, 20% {
  transform: translateY(0) scaleY(1);
  }
}

We need to add in the opacity start point and then transform both the Y position and the vertical scale at the 100% mark, the end of our animation. The last thing we need to do is drop the opacity in order to fade out our circle.

@keyframes scroll {
  ...
  10% {
  opacity: 1;
  }
  100% {
  transform: translateY(36px) scaleY(2);
  opacity: 0.01;
  }
}

Lastly we apply the animation to the circle, along with the ‘transform-origin’ property and the will-change property to allow hardware acceleration. The animation properties are fairly self-explanatory. The cubic-bezier timing function is used to first pull the circle back before dropping it to the bottom of our mouse shape; this adds a playful feel to the animation.

.scroll {
  animation-name: scroll;
  animation-duration: 1.5s;
  animation-timing-function: cubic-bezier(0.650, -0.550, 0.250, 1.500);
  animation-iteration-count: infinite;
  transform-origin: 50% 20.5px;
  will-change: transform;
}

3. Spinning Circles

The animated loading icon is made up of four circles. The circles have no fill, but have alternating stroke-colours.

<svg class="loader" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 340 340">
  <circle cx="170" cy="170" r="160" stroke="#E2007C"/>
  <circle cx="170" cy="170" r="135" stroke="#404041"/>
  <circle cx="170" cy="170" r="110" stroke="#E2007C"/>
  <circle cx="170" cy="170" r="85" stroke="#404041"/>
</svg>

In our CSS, we can set some basic properties to all of our circles and then use the :nth-of-type selector to apply a different stroke-dasharray to each circle.

circle:nth-of-type(1) {
  stroke-dasharray: 550; 
}
circle:nth-of-type(2) {
  stroke-dasharray: 500; 
}
circle:nth-of-type(3) {
  stroke-dasharray: 450;}
circle:nth-of-type(4) {
  stroke-dasharray: 300; 
}

Next, we need to create our keyframe animation. Our animation is really simple: all we need to do is to rotate the circle by 360 degrees. By placing our transformation at the 50% mark of the animation, the circle will also rotate back to its original position.

@keyframes preloader {
  50% {
  transform: rotate(360deg);
  } 
}

With our animation created, we now just need to apply it to our circles. We set the animation name; duration; iteration count and timing function. The ‘ease-in-out’ will give the animation a more playful feel. 

animation-name: preloader;
animation-duration: 3s;
animation-iteration-count: infinite;
animation-timing-function: ease-in-out;

At the moment, we have our loader, but all of the elements are rotating together at the same time. To fix this, we’ll apply some delays. We’ll create our delays using a Sass for loop.

@for $i from 1 through 4 {
  &:nth-of-type(#{$i}) {
  animation-delay: #{$i * 0.15}s;
} }

Due to the delays, our circle now animates in turn, creating the illusion of the circles chasing each other. The only problem with this is that when the page first loads, the circles are static, then they start to move, one at a time. We can achieve the same offset effect, but stop the unwanted pause in our animation by simply setting the delays to a negative value.

animation-delay: -#{$i * 0.15}s;

4. Flying Birds

We start with completely straight vector lines, drawing each frame of our animation, depicting the bird in a different state of flight. We then manipulate the vector points and round the lines and edges. Finally, we put each frame into an equally sized box and place them side-by-side. Export the file as an SVG.

The HTML setup is really simple. We just need to wrap each bird in a container in order to apply multiple animations – one to make the bird fly and the other to move it across the screen.

<div class="bird-container">
  <div class="bird"></div>
</div>

We apply our bird SVG as the background to our bird div and choose the size we want each frame to be. We use the width to roughly calculate the new background position. The SVG has 10 cells, so we multiply our width by 10 and then alter the number slightly until it looks correct.

.bird {
  background-image: url('bird.svg');
  background-size: auto 100%;
  width: 88px;
  height: 125px;
  will-change: background-position;
}
@keyframes fly-cycle {
  100% {
  background-position: -900px 0;
  } 
}

CSS animation has a couple of tricks you may not be aware of. We can use the animation-timing-function to show the image in steps – much like flicking through pages in a notebook to allude to animation.

animation-name: fly-cycle;
animation-timing-function: steps(10);
animation-iteration-count: infinite;
animation-duration: 1s;
animation-delay: -0.5s;

Now we’ve created our fly cycle, our bird is currently flapping her wings but isn’t going anywhere. In order to move her across the screen, we create another keyframe animation. This animation will move the bird across the screen horizontally while also changing the vertical position and the scale to allow the bird to meander across more realistically.

Once we’ve created our animations, we simply need to apply them. We can create multiple copies of our bird and apply different animation times and delays. 

.bird--one {
  animation-duration: 1s;
  animation-delay: -0.5s;
}
.bird--two {
  animation-duration: 0.9s;
  animation-delay: -0.75s;
}

5. Hamburger Crossing

This animation is used all over the web, turning three lines into a cross or close icon. Until fairly recently, the majority of implementations have been achieved using HTML elements, but actually SVG is much more suited to this kind of animation – there’s no longer a need to bloat your buttons code with multiple spans. 

Due to the animatable nature and SVG and its navigable DOM, the code to accomplish the animation or transition changes very little – the technique is the same. 

We start by creating four elements, be it spans inside of a div or paths inside of an SVG. If we’re using spans, we need to use CSS to position them inside the div; if we’re using SVG, this is already taken care of. We want to position lines 2 and 3 in the centre – one on top of another – while spacing lines 1 and 4 evenly above and below, making sure to centre the transform origin.

We’re going to rely on transitioning two properties: opacity and rotation. First of all, we want to fade out lines 1 and 4, which we can target using the :nth-child selector.

.menu-icon.is-active {element-type}:nth-child(1),
.menu-icon.is-active {element-type}:nth-child(4) {
  opacity: 0; }

The only thing left to do is target the two middle lines and rotate them 45 degrees in opposite directions.

.menu-icon.is-active {element-type}:nth-child(2) {
  transform: rotate(45deg); }
.menu-icon.is-active {element-type}:nth-child(3) {
transform: rotate(-45deg); } 

references: codepen, creativebloq

If you want to compare css animations vs javascript check out this guide.

If you want even more info check out these products below:

Create an Animated Interface GIF with Photoshop

Create an Animated Interface GIF with Photoshop

Final product image
What You’ll Be Creating

Ever wanted to turn an app interface PSD into a fully animated demo for your clients or site? Turns out, you can use Photoshop for that, too.

In this tutorial, we will design a simple news iPhone app, and then animate it for client presentation and export it as a GIF file. You’ll learn everything you need to go from idea to animated demo, all inside any recent version of Photoshop.

We’ve used Photoshop CC in this tutorial, but CS5 or 6 would work as well to follow along. You will also need the following stock photo to complete this tutorial. Please download them before you begin, or substitute with a similar picture and adjust the steps accordingly:

First, we will start designing the app’s interface. Make a new file (Control-N) with canvas size 640 px by 1136 px, then click OK.

If instead you already have an app interface designed, you can open it in Photoshop and then jump to the Tap section of this tutorial.

new doc

Click View > New Guide to make new guide, which will help us in placing GUI elements accurately. Set it to Vertical with position 15 px.

guide
guide in place

Add another vertical guide at each side of the canvas with 15 px distance between each guide.

15px guides

Draw another guide, this time horizontally at 40 px, 128 px, and 220 px.

horizontal guides
all guides in place

Add a status bar on the upper most section of your canvas. If you need detailed directions on that, check out the status bar section of our earlier tutorial How to Design an iOS 7 Email App in Photoshop.

Then, make a new layer and then select second section and then fill it a gray color,#2c3137.

status bar

Add the app’s title text on the top part of the interface.

title

Add a logo to the title. I just drew some simple rectangles for the logo, but if you have an existing app icon, you can just import it into a new layer.

logo

Draw a magnifier icon using a combination of two circle shapes and a rounded rectangle, using the same color as the app logo. Place it on the right side of the app.

search icon

On the other side, draw four rounded rectangles for the option icon.

options

Make a new layer with a rectangle section that fits under the titlebar. Fill the next section with a gray color, just as the previous section.

next bar

Add a layer mask onto the layer, and then add a black to white gradient until the bottom is faded.

gradient

Add a menu using the Type Tool, containing the news categories. Set the first menu—in this case, the All option—to be bold, to indicate that the category is active. Duplicate it (Control-J) and then set other menu—in this case, Sport—to be bold, once again to indicate which category is selected.

Now, from the Layers panel, set the Sport menu Opacity to 0% to hide it, as we want the All category to be bold first.

menus

Add a thin arrow for menu navigation, made of rounded rectangles.

nav arrow

Add another arrow onto the other side.

matching nav arrow

Fill the rest of the interface with the gray color. Make sure to put this background underneath all the GUI elements.

background

Draw a light gray rectangle for the individual news section background.

lighter background

Apply Stroke, Inner Glow, and Outer Glow to add more contrast to the news area. Double click the layer and then use the following settings from the screenshots below:

stroke
inner glow
outer glow

Draw a white rounded rectangle on the top part of the previous shape. We will put news image here.

news element

Apply Inner Glow into the white shape with the following settings:

news entry glow

Select a photo from the Tuts+ Stock Photo set you previously downloaded, or any other photos you’d like to use, and place it covering the white rounded rectangle shape.

photo in news

Hit Control-Alt-G to convert selected photo layer into a Clipping Mask. The photo will automatically go inside layer behind it. And, here’s what you see:A perfectly placed photo on top of the individual news area.

photo placement

Add text for the news content. Make sure to add contrast to the news text for a better reading experience by varying font type, color, and size.

styled text

Let’s add icons into the news element design. Draw two small rounded rectangles without Fill and 1 pt white stroke.

icons

Double click the layer and then add layer style Color Overlay. Use #708196 for its color.

add color overlay

Repeat previous process, but this time uses a combination of a rounded rectangle and a rectangle.

another icon

Add a small circle shape. Now, we have a tag icon. Sweet!

tag and link icons

So far, this is our app design at 100% magnification.

100 magnified app UI

Add other individual news articles into the app by duplicating the news element layers, customizing them appropriately.

filled articles

Add bigger news area. This will be shown when an individual news is selected.

larger news area

Put all the individual news elements and big news stories in separate layer groups. You want to assure every layer is carefully placed into a layer group according to its element.

For example, you want each layer that made the first individual news section placed together in a layer group, and the elements for full-screen news articles in other groups. This will help you to work easier while making the animation.

layer groups

For now, we will not use this big news section. So, set its Opacity to 0%.

We now need to design the tap indicator. Make a new layer group and name it tap. Next, draw a white circle shape. Set its Opacity to 50%.

tap sector

Duplicate the circle shape by pressing Control-J. Make it larger, set stroke to 3 ptwith a white color, and remove the Fill color.

tap border

Add another circle shape, this time thinner. Set its stroke size to 2 pt.

thinner circle

Hide all the layers inside tap layer group we have just made, as you won’t want the taps to show up when the UI is first loaded, but instead will only display them when the animation is fixing to transition to a selected element.

Now, we’re finally ready to start building our UI animation. Open the Timeline panel and then make a new frame.

timeline

Make another new frame.

another new frame

Now it’s time to reveal the tap layer group. When showing a scrolling scene, hide the two stroked circles, and we are going to use this condition to indicate scroll gesture. It will appear more as a continuous stroke, whereas the outer stroked circles give a ripple appearance more consistent with a single tap to select an item.

scrolling circle

Change the duration to 1 second for first frame and 0.2 seconds for second frame.

duration

Add another frame.

another new frame

Activate the Tap layer group and all the news grid layers. Use Move Tool to move them up in your list of layers.

move layer groups

To automatically make a smooth animation between current and previous frame, click Tween from Timeline panel menu.

tween

Set the tween to 5 for the added frame.

tween of 5

Now, we have an animation of the news grid moving upward on each frame.

auto-generated news grid animation
news grid animation 2

If you think that the animation is too fast, you can make it slower by selecting all the frames and setting the duration to 0.2 seconds.

slower animation

Test the animation by clicking the play icon in the Timeline panel. Don’t forget to set the animation to Forever; this way the animation is looped.

play

Our current animation contains the news grid moving upward. In next frame, we need to put it back to previous condition so it will continue seamlessly with the first frame. To do this, copy the second frame and then paste it at the last position by choosing Paste After Selection in the dialogue box.

copy frame
paste frame
paste after selection

Apply the Tween command again to make a new animation between last and next-to-last frames.

tween again
5 frame tween

Add a new frame and hide the tap indicator.

hidden tap

So far, this is the animation we get, which gives us a basic scrolling UI.

animated UI scroll

Now it’s time to animate the selection of a link in the menu. First, make a new frame. In this frame, set the Opacity text menu with the selected bold variant of All from the menu set to 0% and Sport‘s selected variant’s transparency set to 100%.

bold sport

Activate the Tap layer group and reveal all its layers. Change frame duration to 0.2 seconds.

add a tap

Make a new frame with a duration of 0.1 seconds. This time hides the thinnest stroked circle.

hide outer circle

Add another frame and hide next stroked circle.

hide next circle

Add a new frame and hide the tap layer group.

hide tap

Make a new frame and then set the Opacity of every news story in the grid without the sport tag to 0%.

hide non-sport stories

Still in this frame, drag the individual sports news stories upward in the grid, filling empty spaces above them.

filled sport story sections

Tween between current frame and the previous. For faster animation, set added frames to 3.

animate change

Set duration in the last frame to 2 seconds.

2 second last frame

For this tap, this is the animation we have.

sport animation

Next, we are going to select one of the news articles and reveal it in full screen. First, make new frame with duration 0.2 seconds and then reveal all layers inside the Tap layer group.

tap news start

Add new frame and then set its duration to 0.1 seconds. Hide thinnest circle stroke.

hide thin circle again

Add another frame and then hide next stroked circle.

hide second circle again

Add another frame with duration 0.1 seconds. Hide the Tap layer group, and make a new frame. Reveal the big news section we made earlier in Section 1 Step 28 by setting its Opacity to 100%. Hide the small news grid by setting its Opacity to 0%.

show large story

Add tween animation between the current frame and the previous ones.

tween news story
finished full news story

This is what we have for this animation.

finished news animation

From Timeline panel, click Flatten Frames Into Layers.

flatten layers into frames

Each frame will be converted into a flat layer. If you have 33 frames, you will also get 33 flat layers: layer Frame 1 taken from content of frame 1, layer Frame 2 taken from frame 2, and so on.

new frames

Select all frame layers in Layers panel.

select all

Drag the layers onto the iPhone photo that you downloaded previously.

iphone pic

In Timeline panel, select Create Frame Animation and then click New Framebutton.

create frame animation

Make sure all layers are still selected. Hit Control-T to perform a transformation. Hold Control and then drag each corner and place them onto the screen corner.

place news animation into iPhone screen
fit edges
again
and again
and yet again
and now its good

Make a new frame for each layer. Put layer Frame 1 in the first frame, layer Frame 2in second frame, layer Frame 3 in third frame, and so on. You also want to match the duration for each of the frame. Make sure to set the loop to Forever, so the animation will keep on looping.

animate everything

Look at picture below for an example. Layer Frame 23 is revealed on frame 23. Layer Frame 25 is revealed on frame 25, and so on. Continue this for each frame.

keep animating

It’s time to export the result as animated GIF file. Select Save for Web in the File menu, and select GIF as file type. Play around with available settings to get the optimum file size. Test the animation result by clicking on the play button. Make sure to set its Looping Options to Forever.

save as gif

And that’s it: you’ve designed a demo app UI, animated it, and put the animation inside an iPhone picture to make the animation look like it’s running on a real device.

 

Reference: tutsplus