{"id":3367,"date":"2017-03-09T19:42:36","date_gmt":"2017-03-09T19:42:36","guid":{"rendered":"http:\/\/freshinbox.com\/blog\/?p=3367"},"modified":"2017-03-09T19:42:36","modified_gmt":"2017-03-09T19:42:36","slug":"how-to-restart-css-animations-in-email-using-the-active-pseudo-class","status":"publish","type":"post","link":"https:\/\/freshinbox.com\/blog\/how-to-restart-css-animations-in-email-using-the-active-pseudo-class\/","title":{"rendered":"How to Restart CSS Animations in Email Using The :active Pseudo-Class"},"content":{"rendered":"<div style=\"border:2px solid #aaaaaa;padding:10px;display:inline-block;margin:20px;\"><a href=\"#r\" id=\"replay\">Replay animation<\/a><\/p>\n<div class=\"anim-container\">\n<div class=\"rocket\"><\/div>\n<\/div>\n<\/div>\n<p>One of the questions often asked about CSS animations is &#8220;Why use CSS animations when an animated gif works in many more clients?&#8221;<\/p>\n<p>Until now, the answer seems to be that CSS animations are more fluid, has smaller filesize and a much higher color palette (gif images are limited to 256 colors). There is now another reason to use CSS animations &#8211; the ability to play the animations on demand.<\/p>\n<p>This article shows you a <a href=\"https:\/\/www.emailonacid.com\/blog\/article\/email-development\/restart-css-animations-in-email-using-active-pseudo-class\">technique to restart CSS animations<\/a> with a single click or tap using the :active pseudo-class.<\/p>\n<p><BR><BR><\/p>\n<div style=\"padding:10px; border: 2px solid #99C731;background-color:#FFF8DC;border-radius:5px;\">\n<form action=\"https:\/\/freshinbox1.createsend.com\/t\/i\/s\/adrmi\/\" method=\"post\" id=\"subForm\">\n<span class=\"fisub_header\" style=\"font-weight:bold;\">Subscribe to the #EmailGeeks Newsletter<\/span>\n<p><input id=\"fieldEmail\" name=\"cm-adrmi-adrmi\" type=\"email\" style=\"width:90%\" required placeholder=\"Your Email Address\" \/><\/p>\n<p><button type=\"submit\">Subscribe<\/button><\/p>\n<\/form>\n<\/div>\n<style>\n.anim-container{\n  width:300px;\n  height:50px;\n  background-color:green;\n}\n.rocket{\n  background-image:url(https:\/\/marketing.emailonacid.com\/hubfs\/images\/emails\/eoa2016\/November_Innovative_Email\/NovInt_rocket.png);\n  background-size:cover;\n  display:inline-block;\n  width:40px;\n  height:40px;\n  margin:5px;\n  transform:rotate(90deg);\n}\n.rocket{\n  -webkit-animation: moverocket 2s; \n}\n#replay:active ~ .anim-container .rocket{\n  -webkit-animation-name:none;\n}\n@-webkit-keyframes moverocket{\n  from {\n    transform:translateX(0px) rotate(90deg) ;\n  }\n  to{\n    transform:translateX(250px) rotate(90deg) ;\n  }\n}\n<\/style>\n","protected":false},"excerpt":{"rendered":"<p>One of the questions often asked about CSS animations is &#8220;Why use CSS animations when an animated gif works in many more clients?&#8221;<BR><BR><\/p>\n<p>Until now, the answer seems to be that CSS animations are more fluid, has smaller filesize and a much higher color palette (gif images are limited to 256 colors). There is now another reason to use CSS animations &#8211; the ability to play the animations on demand&#8230;<\/p>\n","protected":false},"author":2,"featured_media":3378,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[48,24,25,47],"tags":[],"_links":{"self":[{"href":"https:\/\/freshinbox.com\/blog\/wp-json\/wp\/v2\/posts\/3367"}],"collection":[{"href":"https:\/\/freshinbox.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/freshinbox.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/freshinbox.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/freshinbox.com\/blog\/wp-json\/wp\/v2\/comments?post=3367"}],"version-history":[{"count":11,"href":"https:\/\/freshinbox.com\/blog\/wp-json\/wp\/v2\/posts\/3367\/revisions"}],"predecessor-version":[{"id":3379,"href":"https:\/\/freshinbox.com\/blog\/wp-json\/wp\/v2\/posts\/3367\/revisions\/3379"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/freshinbox.com\/blog\/wp-json\/wp\/v2\/media\/3378"}],"wp:attachment":[{"href":"https:\/\/freshinbox.com\/blog\/wp-json\/wp\/v2\/media?parent=3367"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/freshinbox.com\/blog\/wp-json\/wp\/v2\/categories?post=3367"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/freshinbox.com\/blog\/wp-json\/wp\/v2\/tags?post=3367"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}