title: CSS3 animation for width in various %
body: <p><a href="https://i.stack.imgur.com/SGEQZ.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SGEQZ.gif" alt="enter image description here"></a></p>
  
  <p>I've used CSS3 animation to expand the bars, but the issue is that the precentage needs to be inserted into the @keyframes-code. In the HTML the custom width is inserted as inline css.</p>
  
  <p>Is there a way to animate to the amount of the inlined CSS width and not whats inserted in the @keyframe?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>#dataanalysis td figure {
    animation: aw 2s normal;
  }
  
  @keyframes aw {
    0% {
      width: 0%;
    }
    100% {
      width: 100%;
    }
  }
  #dataanalysis {
    width: 100%;
    margin-top: 3rem;
    background: #26272b;
    color: white;
    border-collapse: collapse;
    font-size: .7rem;
    font-weight: 300;
    -webkit-font-smoothing: antialiased;
  }
  #dataanalysis td {
    border: solid 1px black;
    padding: .5rem;
    word-wrap: break-word;
    height: 25px;
  }
  #dataanalysis td:first-child {
    width: 140px;
    padding-left: .5rem;
  }
  #dataanalysis td:nth-child(2n) {
    border-right: none;
  }
  #dataanalysis td:last-child {
    text-align: right;
    width: 25px;
    border-left: none;
  }
  #dataanalysis td figure {
    background: linear-gradient(to right, #f24f37 0%, #cd2134 100%);
    height: .8rem;
    margin: 0 0 0 .5rem;
    border-radius: 0.3rem;
    border: 1px solid black;
  }
  #dataanalysis td img {
    width: .8rem;
    padding-left: .8rem;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;table id="dataanalysis"&gt;
              &lt;tbody&gt;
                &lt;tr&gt;
                  &lt;td&gt;Acousticness
                    &lt;a href="#" data-tooltip="A confidence measure from 0.0 to 1.0 of whether the track is acoustic. 1.0 represents high confidence the track is acoustic."&gt;&lt;img src="/assets/img/info.svg" alt="tip"&gt;&lt;/a&gt;
                  &lt;/td&gt;
                  &lt;td&gt;&lt;figure style="width:87%"&gt;&lt;/figure&gt;&lt;/td&gt;&lt;td&gt;87%&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td&gt;Danceability
                    &lt;a href="#" data-tooltip="Danceability describes how suitable a track is for dancing based on a combination of musical elements including tempo, rhythm stability, beat strength, and overall regularity. A value of 0.0 is least danceable and 1.0 is most danceable."&gt;&lt;img src="/assets/img/info.svg" alt="tip"&gt;&lt;/a&gt;
                  &lt;/td&gt;
                  &lt;td&gt;&lt;figure style="width:15%"&gt;&lt;/figure&gt;&lt;/td&gt;&lt;td&gt;15%&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td&gt;Energy
                    &lt;a href="#" data-tooltip="Energy is a measure from 0.0 to 1.0 and represents a perceptual measure of intensity and activity. Typically, energetic tracks feel fast, loud, and noisy. For example, death metal has high energy, while a Bach prelude scores low on the scale. Perceptual features contributing to this attribute include dynamic range, perceived loudness, timbre, onset rate, and general entropy."&gt;&lt;img src="/assets/img/info.svg" alt="tip"&gt;&lt;/a&gt;
                  &lt;/td&gt;
                  &lt;td&gt;&lt;figure style="width:49%"&gt;&lt;/figure&gt;&lt;/td&gt;&lt;td&gt;49%&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td&gt;Instrumentalness
                    &lt;a href="#" data-tooltip="Predicts whether a track contains no vocals. "Ooh" and "aah" sounds are treated as instrumental in this context. Rap or spoken word tracks are clearly "vocal". The closer the instrumentalness value is to 1.0, the greater likelihood the track contains no vocal content. Values above 0.5 are intended to represent instrumental tracks, but confidence is higher as the value approaches 1.0."&gt;&lt;img src="/assets/img/info.svg" alt="tip"&gt;&lt;/a&gt;
                  &lt;/td&gt;
                  &lt;td&gt;&lt;figure style="width:32%"&gt;&lt;/figure&gt;&lt;/td&gt;&lt;td&gt;32%&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td&gt;Liveness
                    &lt;a href="#" data-tooltip="Detects the presence of an audience in the recording. Higher liveness values represent an increased probability that the track was performed live. A value above 0.8 provides strong likelihood that the track is live."&gt;&lt;img src="/assets/img/info.svg" alt="tip"&gt;&lt;/a&gt;
                  &lt;/td&gt;
                  &lt;td&gt;&lt;figure style="width:65%"&gt;&lt;/figure&gt;&lt;/td&gt;&lt;td&gt;65%&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td&gt;speechiness
                    &lt;a href="#" data-tooltip="Speechiness detects the presence of spoken words in a track. The more exclusively speech-like the recording (e.g. talk show, audio book, poetry), the closer to 1.0 the attribute value. Values above 0.66 describe tracks that are probably made entirely of spoken words. Values between 0.33 and 0.66 describe tracks that may contain both music and speech, either in sections or layered, including such cases as rap music. Values below 0.33 most likely represent music and other non-speech-like tracks."&gt;&lt;img src="/assets/img/info.svg" alt="tip"&gt;&lt;/a&gt;
                  &lt;/td&gt;
                  &lt;td&gt;&lt;figure style="width:11%"&gt;&lt;/figure&gt;&lt;/td&gt;&lt;td&gt;11%&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td&gt;Valence / Happiness
                    &lt;a href="#" data-tooltip="A measure from 0.0 to 1.0 describing the musical positiveness conveyed by a track. Tracks with high valence sound more positive (e.g. happy, cheerful, euphoric), while tracks with low valence sound more negative (e.g. sad, depressed, angry)."&gt;&lt;img src="/assets/img/info.svg" alt="tip"&gt;&lt;/a&gt;
                  &lt;/td&gt;
                  &lt;td&gt;&lt;figure style="width:91%"&gt;&lt;/figure&gt;&lt;/td&gt;&lt;td&gt;91%&lt;/td&gt;
              &lt;/tbody&gt;
            &lt;/table&gt;</code></pre>
  </div>
  </div>
  </p>