{"id":21756,"date":"2014-07-29T15:01:04","date_gmt":"2014-07-29T07:01:04","guid":{"rendered":"https:\/\/www.hongkiat.com\/blog\/?p=21756"},"modified":"2025-04-24T17:16:01","modified_gmt":"2025-04-24T09:16:01","slug":"css3-animation-steps","status":"publish","type":"post","link":"https:\/\/www.hongkiat.com\/blog\/css3-animation-steps\/","title":{"rendered":"Controlling CSS3 Animation with steps() Function"},"content":{"rendered":"<p>Animation is one of the greatest features introduced to CSS. In the past, web animation was only available in the JavaScript or Flash territory. But, today, many websites opt to use <strong>CSS for adding subtle animation<\/strong>. In previous articles, we have gone through how to do some cool things with CSS animation like <a href=\"https:\/\/www.hongkiat.com\/blog\/css-marquee\/\">adding a marquee effect<\/a> and <a href=\"https:\/\/www.hongkiat.com\/blog\/css3-bounce-effect\/\">adding bounce effect<\/a> to something.<\/p>\n<p>In this article, we will once again dive into CSS animation. This time, we are going to discuss a CSS animation function, <code>steps()<\/code>, that <strong>enables us to control the animation\u2019s movement<\/strong> \u2014 don\u2019t freak out, it\u2019s not as puzzling as it sounds. Let\u2019s take a look.<\/p>\n<p class=\"note\"><strong>Recommended Reading<\/strong>: <a href=\"https:\/\/www.hongkiat.com\/blog\/creative-css-animations\/\">38 Inspiring CSS3 Animation Demos<\/a><\/p>\n<h2>So what is it?<\/h2>\n<p>Normally, the animation in CSS will go straight from start to end at the specified duration. <code>steps()<\/code> is part of the animation timing function. It allows us to control the animation to move gradually. The very best example that shows how the <code>steps()<\/code> works would be <strong>the second hand<\/strong> of an analog clock; the clock\u2019s second hand does not move continuously, instead its movements are split into stages. So let\u2019s replicate it with CSS animation and <code>steps()<\/code>.<\/p>\n<h2>Replicating the Second Hand of a Clock<\/h2>\n<p>Let\u2019s first add the keyframes that will rotate the second hand for 360 degrees; the rotation will start at 90 degrees (or at 12 o\u2019clock). Note that the following code may need a prefix (<code>-moz-<\/code>, <code>-o-<\/code>, and <code>-ms-<\/code>) in order to work across browsers.<\/p>\n<pre>\n@-webkit-keyframes rotation {\n    from {\n        transform: rotate(90deg);\n    }\n    to {\n        transform: rotate(450deg);\n    }\n}\n<\/pre>\n<p>The second hand will move steadily every second and complete a 360 degree rotation in 60 seconds. Thus, here we will set the animation duration for <code>60s<\/code> and this tells the browser to complete it in 60 steps with <code>steps(60)<\/code> like so.<\/p>\n<pre>\n.second {\n    animation: rotation 60s steps(60) infinite;\n    transform-origin: 100% 50%;\n\n    \/* styles decoration *\/\n    background-color: #e45341;\n    height: 2px;\n    margin-top: -1px;\n    position: absolute;\n    top: 50%;\n    width: 50%;\n}\n<\/pre>\n<p>We have created two demos for this; one with <code>steps()<\/code> and one with <code>linear<\/code>. You can see the different moves from this screenshot below.<\/p>\n<p><figure><img decoding=\"async\" alt=\"CSS steps animation second hand\" src=\"https:\/\/assets.hongkiat.com\/uploads\/css3-animation-steps\/second-hand.gif\"><\/figure>\n<\/p>\n<p>At this point, hopefully, you can figure out and imagine how <code>steps()<\/code> works. To see the demo in action, follow this link below.<\/p>\n<div class=\"button\">\n    <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/hongkiat.github.io\/css3-animation-steps\/\">View Demo<\/a>\n    <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/github.com\/hongkiat\/css3-animation-steps\/\">Download Source<\/a>\n<\/div>\n<h2>More Inspiration\u2026<\/h2>\n<p>In addition, here we have collected a few terrific experiments and demonstrations that exploit <code>steps()<\/code> from many web developers. Check them out and I hope you can derive some inspiration from them.<\/p>\n<ul>\n<li><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/lea.verou.me\/2011\/09\/pure-css3-typing-animation-with-steps\/\">Pure CSS3 typing animation with steps()<\/a> by Lea Verou<\/li>\n<li><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/codepen.io\/\/rachelnabors\/pen\/bpAJH\">Cat Walk<\/a> by Rachel Nabors<\/li>\n<li><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/codepen.io\/\/jkneb\/pen\/smtHA\">Ken\u2019s Street Fighter II<\/a> by David Walsh<\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>Animation is one of the greatest features introduced to CSS. In the past, web animation was only available in the JavaScript or Flash territory. But, today, many websites opt to use CSS for adding subtle animation. In previous articles, we have gone through how to do some cool things with CSS animation like adding a&hellip;<\/p>\n","protected":false},"author":113,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[352],"tags":[507,3498],"topic":[4520],"class_list":["entry-content","is-maxi"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v22.8 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Controlling CSS3 Animation with steps() Function - Hongkiat<\/title>\n<meta name=\"description\" content=\"Animation is one of the greatest features introduced to CSS. In the past, web animation was only available in the JavaScript or Flash territory. But,\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.hongkiat.com\/blog\/css3-animation-steps\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Controlling CSS3 Animation with steps() Function\" \/>\n<meta property=\"og:description\" content=\"Animation is one of the greatest features introduced to CSS. In the past, web animation was only available in the JavaScript or Flash territory. But,\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.hongkiat.com\/blog\/css3-animation-steps\/\" \/>\n<meta property=\"og:site_name\" content=\"Hongkiat\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/hongkiatcom\" \/>\n<meta property=\"article:published_time\" content=\"2014-07-29T07:01:04+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-04-24T09:16:01+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/assets.hongkiat.com\/uploads\/css3-animation-steps\/second-hand.gif\" \/>\n<meta name=\"author\" content=\"Thoriq Firdaus\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@tfirdaus\" \/>\n<meta name=\"twitter:site\" content=\"@hongkiat\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Thoriq Firdaus\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css3-animation-steps\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css3-animation-steps\\\/\"},\"author\":{\"name\":\"Thoriq Firdaus\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/e7948c7a175d211496331e4b6ce55807\"},\"headline\":\"Controlling CSS3 Animation with steps() Function\",\"datePublished\":\"2014-07-29T07:01:04+00:00\",\"dateModified\":\"2025-04-24T09:16:01+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css3-animation-steps\\\/\"},\"wordCount\":382,\"commentCount\":6,\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css3-animation-steps\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/css3-animation-steps\\\/second-hand.gif\",\"keywords\":[\"CSS\",\"CSS Animation\"],\"articleSection\":[\"Web Design\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css3-animation-steps\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css3-animation-steps\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css3-animation-steps\\\/\",\"name\":\"Controlling CSS3 Animation with steps() Function - Hongkiat\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css3-animation-steps\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css3-animation-steps\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/css3-animation-steps\\\/second-hand.gif\",\"datePublished\":\"2014-07-29T07:01:04+00:00\",\"dateModified\":\"2025-04-24T09:16:01+00:00\",\"description\":\"Animation is one of the greatest features introduced to CSS. In the past, web animation was only available in the JavaScript or Flash territory. But,\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css3-animation-steps\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css3-animation-steps\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css3-animation-steps\\\/#primaryimage\",\"url\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/css3-animation-steps\\\/second-hand.gif\",\"contentUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/css3-animation-steps\\\/second-hand.gif\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css3-animation-steps\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Controlling CSS3 Animation with steps() Function\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\",\"name\":\"Hongkiat\",\"description\":\"Tech and Design Tips\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\",\"name\":\"Hongkiat.com\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-content\\\/uploads\\\/hkdc-logo-rect-yoast.jpg\",\"contentUrl\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-content\\\/uploads\\\/hkdc-logo-rect-yoast.jpg\",\"width\":1200,\"height\":799,\"caption\":\"Hongkiat.com\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/hongkiatcom\",\"https:\\\/\\\/x.com\\\/hongkiat\",\"https:\\\/\\\/www.pinterest.com\\\/hongkiat\\\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/e7948c7a175d211496331e4b6ce55807\",\"name\":\"Thoriq Firdaus\",\"description\":\"Thoriq is a writer for Hongkiat.com with a passion for web design and development. He is the author of Responsive Web Design by Examples, where he covered his best approaches in developing responsive websites quickly with a framework.\",\"sameAs\":[\"https:\\\/\\\/thoriq.com\",\"https:\\\/\\\/x.com\\\/tfirdaus\"],\"jobTitle\":\"Web Developer\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/author\\\/thoriq\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Controlling CSS3 Animation with steps() Function - Hongkiat","description":"Animation is one of the greatest features introduced to CSS. In the past, web animation was only available in the JavaScript or Flash territory. But,","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.hongkiat.com\/blog\/css3-animation-steps\/","og_locale":"en_US","og_type":"article","og_title":"Controlling CSS3 Animation with steps() Function","og_description":"Animation is one of the greatest features introduced to CSS. In the past, web animation was only available in the JavaScript or Flash territory. But,","og_url":"https:\/\/www.hongkiat.com\/blog\/css3-animation-steps\/","og_site_name":"Hongkiat","article_publisher":"https:\/\/www.facebook.com\/hongkiatcom","article_published_time":"2014-07-29T07:01:04+00:00","article_modified_time":"2025-04-24T09:16:01+00:00","og_image":[{"url":"https:\/\/assets.hongkiat.com\/uploads\/css3-animation-steps\/second-hand.gif","type":"","width":"","height":""}],"author":"Thoriq Firdaus","twitter_card":"summary_large_image","twitter_creator":"@tfirdaus","twitter_site":"@hongkiat","twitter_misc":{"Written by":"Thoriq Firdaus","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.hongkiat.com\/blog\/css3-animation-steps\/#article","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/css3-animation-steps\/"},"author":{"name":"Thoriq Firdaus","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/e7948c7a175d211496331e4b6ce55807"},"headline":"Controlling CSS3 Animation with steps() Function","datePublished":"2014-07-29T07:01:04+00:00","dateModified":"2025-04-24T09:16:01+00:00","mainEntityOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/css3-animation-steps\/"},"wordCount":382,"commentCount":6,"publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/css3-animation-steps\/#primaryimage"},"thumbnailUrl":"https:\/\/assets.hongkiat.com\/uploads\/css3-animation-steps\/second-hand.gif","keywords":["CSS","CSS Animation"],"articleSection":["Web Design"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.hongkiat.com\/blog\/css3-animation-steps\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.hongkiat.com\/blog\/css3-animation-steps\/","url":"https:\/\/www.hongkiat.com\/blog\/css3-animation-steps\/","name":"Controlling CSS3 Animation with steps() Function - Hongkiat","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/css3-animation-steps\/#primaryimage"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/css3-animation-steps\/#primaryimage"},"thumbnailUrl":"https:\/\/assets.hongkiat.com\/uploads\/css3-animation-steps\/second-hand.gif","datePublished":"2014-07-29T07:01:04+00:00","dateModified":"2025-04-24T09:16:01+00:00","description":"Animation is one of the greatest features introduced to CSS. In the past, web animation was only available in the JavaScript or Flash territory. But,","breadcrumb":{"@id":"https:\/\/www.hongkiat.com\/blog\/css3-animation-steps\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.hongkiat.com\/blog\/css3-animation-steps\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hongkiat.com\/blog\/css3-animation-steps\/#primaryimage","url":"https:\/\/assets.hongkiat.com\/uploads\/css3-animation-steps\/second-hand.gif","contentUrl":"https:\/\/assets.hongkiat.com\/uploads\/css3-animation-steps\/second-hand.gif"},{"@type":"BreadcrumbList","@id":"https:\/\/www.hongkiat.com\/blog\/css3-animation-steps\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.hongkiat.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Controlling CSS3 Animation with steps() Function"}]},{"@type":"WebSite","@id":"https:\/\/www.hongkiat.com\/blog\/#website","url":"https:\/\/www.hongkiat.com\/blog\/","name":"Hongkiat","description":"Tech and Design Tips","publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.hongkiat.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.hongkiat.com\/blog\/#organization","name":"Hongkiat.com","url":"https:\/\/www.hongkiat.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.hongkiat.com\/blog\/wp-content\/uploads\/hkdc-logo-rect-yoast.jpg","contentUrl":"https:\/\/www.hongkiat.com\/blog\/wp-content\/uploads\/hkdc-logo-rect-yoast.jpg","width":1200,"height":799,"caption":"Hongkiat.com"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/hongkiatcom","https:\/\/x.com\/hongkiat","https:\/\/www.pinterest.com\/hongkiat\/"]},{"@type":"Person","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/e7948c7a175d211496331e4b6ce55807","name":"Thoriq Firdaus","description":"Thoriq is a writer for Hongkiat.com with a passion for web design and development. He is the author of Responsive Web Design by Examples, where he covered his best approaches in developing responsive websites quickly with a framework.","sameAs":["https:\/\/thoriq.com","https:\/\/x.com\/tfirdaus"],"jobTitle":"Web Developer","url":"https:\/\/www.hongkiat.com\/blog\/author\/thoriq\/"}]}},"jetpack_featured_media_url":"https:\/\/","jetpack_shortlink":"https:\/\/wp.me\/p4uxU-5EU","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/21756","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/users\/113"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/comments?post=21756"}],"version-history":[{"count":3,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/21756\/revisions"}],"predecessor-version":[{"id":74114,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/21756\/revisions\/74114"}],"wp:attachment":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/media?parent=21756"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/categories?post=21756"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/tags?post=21756"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/topic?post=21756"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}