~/Blog

Brandon Rozek

Photo of Brandon Rozek

PhD Student @ RPI studying Automated Reasoning in AI and Linux Enthusiast.

Animatable: Visual

Published on

Updated on

2 minute reading time

Warning: This post has not been modified for over 2 years. For technical posts, make sure that it is still relevant.

Hello everyone! This is part 5 of my series on animation. Today’s post will be short, since we’re only going to talk about color and opacity.

I’ll give a shout-out to http://csstriggers.com, if you are interested in CSS Animation performance, then check them out to see what triggers a repaint and/or reflow. Take a look at the other posts in this series!

This post goes with a Codepen demo{.broken_link} I made, I’ll reference it later in this post.

color

  • Accepts any color value
  • Typically inherits it’s color from the parent element

The color property sets the color of an element’s text content and its decoration. During the animation, the browser sees the colors in their red, green, and blue (rgb) components, then increments/decrements those values until it reaches the color it’s animating to. For example, in the Codepen demo (#1), the color of the text is changing from red or rgb(255, 0, 0) to green or rgb(0, 255, 0). Meaning the red component is going from 255 to 0 and the green component is going from 0 to 255 during the animation.

opacity

  • Accepts any number from [0, 1]
  • Initial Value: 1

Opacity sets the transparency of an element and it’s decendants. Unlike display: none;, when the element is opacity: 0; the element still holds it’s space on the page. In the Codepen demo (#2), you can see the element and it’s children fading out.

Conclusion

I used to work on a chat application called Babbler. In it, I used opacity to fade in the messages as the user recieved them. With all these different types of animations, you can visually show the user what’s going on in your website/application. Doing this series helps me, (as well as you, I hope) recognize all the different properties and possibilities for animation. This is the second to last part of this series, meaning that the next part is the finale. I’m somewhat sad to see this series ending but excited at the same time. Until next time, have fun animating. 🙂

Reply via Email Buy me a Coffee
Was this useful? Feel free to share: Hacker News Reddit Twitter

Published a response to this? :