<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Michelle Tamar</title>
    <description>The latest articles on DEV Community by Michelle Tamar (@michelletamar).</description>
    <link>https://dev.to/michelletamar</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F953314%2F159e8940-7e64-4ee0-ac11-469097618d95.jpeg</url>
      <title>DEV Community: Michelle Tamar</title>
      <link>https://dev.to/michelletamar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/michelletamar"/>
    <language>en</language>
    <item>
      <title>How to create a rainbow loop background with CSS - Beginner Friendly</title>
      <dc:creator>Michelle Tamar</dc:creator>
      <pubDate>Mon, 24 Oct 2022 20:35:56 +0000</pubDate>
      <link>https://dev.to/michelletamar/how-to-create-a-rainbow-loop-background-with-css-beginner-friendly-2ha3</link>
      <guid>https://dev.to/michelletamar/how-to-create-a-rainbow-loop-background-with-css-beginner-friendly-2ha3</guid>
      <description>&lt;p&gt;In 2013 Tumblr (simpler times), if you had a rainbow background on your theme, you were IT! All the popular Tumblrs had it. It was a &lt;em&gt;thing&lt;/em&gt;. &lt;/p&gt;

&lt;p&gt;I remember trying to figure out how to create this magical background, asking others on Tumblr, but everyone would keep this information a top secret. I thought you needed to be an advanced wizard coder to create it. Turns out, it's super duper easy. You only need CSS and a few lines of code!&lt;/p&gt;

&lt;h2&gt;
  
  
  🌈 It's Rainbow Time 🌈
&lt;/h2&gt;

&lt;p&gt;Open up your style sheet and start typing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;body {
  background-color: #f3bbff;
  animation: bgColor 50s infinite linear;
  margin: 0px;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can choose any background color you like. I chose pink because it's the best color, obviously. You can also set the margin to whatever you want.&lt;/p&gt;

&lt;p&gt;But... wait a minute...&lt;/p&gt;

&lt;h2&gt;
  
  
  🤔 Animations? 🤔
&lt;/h2&gt;

&lt;p&gt;CSS Animations are the process of animating the objects (or elements) on a web page. We have three major categories to perform animations:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Transformation&lt;/strong&gt; — Transforming the dimensions, rescaling the objects, moving them from point A to B, etc.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Transitions&lt;/strong&gt; — Performing the transformations smoothly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Keyframes&lt;/strong&gt; — Changing the animation (property, value, etc.) at a given time or state.&lt;/p&gt;

&lt;p&gt;For a rainbow background, we will be using Keyframes, as we need the background color to change to another after a set amount of time. It's super easy, trust me. But more on that in a second.&lt;/p&gt;

&lt;p&gt;Breaking down what we just wrote:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;bgColor&lt;/code&gt;: what we name our animation, for clean code and ease of understanding. &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;50s&lt;/code&gt;: we set the time duration we want for each color.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;infinite&lt;/code&gt;: this makes the color transition loop indefinitely, creating that "rainbow effect".&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;linear&lt;/code&gt;: this makes the color transition smooth, so the colors "fade" into each other. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now, back to...&lt;/p&gt;

&lt;h2&gt;
  
  
  🔑 Keyframes 🖼️
&lt;/h2&gt;

&lt;p&gt;The keyframes, are, well, the &lt;em&gt;key&lt;/em&gt; frames of our animation.  They allow us to build and define multicomponent, multi-state animations - from A to B to C to D to E and so forth. When we use keyframes, we can control the timing of the animation: when it starts, how many times it should repeat, and how long it should last.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;To be very technical:&lt;/em&gt;&lt;br&gt;
Keyframes start with an offset of 0% and end with an offset of 100%. The % is a percentage of the time through the animation sequence at which the specified keyframe should occur.&lt;/p&gt;

&lt;p&gt;Keyframes let us build complex animations, but really, they're not complex at all.&lt;/p&gt;

&lt;p&gt;Let's define our keyframes for our beautiful rainbow loop background:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@keyframes bgColor {
  10% {
    background-color: #a43535;
  }
  20% {
    background-color: #ff7b00;
  }
  30% {
    background-color: #ffff51;
  }
  40% {
    background-color: #a7ff4e;
  }
  50% {
    background-color: #7addfe;
  }
  60% {
    background-color: #6b6bfd;
  }
  70% {
    background-color: #ca61ff;
  }
  80% {
    background-color: #ff54af;
  }
  90% {
    background-color: #f3bbff;
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Keyframes span from a range of 100%, and you can split it up into as many pieces as you'd like within that 100%. So choose your colors, assign them into however many percentages you need (10% per color is easy - you can also do 25%, or 5%, or 1% if you're brave...) and voila!&lt;/p&gt;

&lt;p&gt;Literally, that's it. You're done. Coding queen/king come through!&lt;/p&gt;

&lt;h2&gt;
  
  
  🥳
&lt;/h2&gt;

&lt;p&gt;Check out the result on &lt;a href="https://codepen.io/michellesucho/pen/LYrYYVQ"&gt;Codepen&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>css</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
