Back to Snippets

Animated Bar Chart CSS

Seven bars for the days of a week rise from the baseline one after another when the page loads. Hover a bar and its value appears above it, and the gridlines behind the bars give the eye something to read the heights against.

The data is a definition list. Each dt is a day label and each dd is a bar whose height comes from a custom property set inline as a percentage, so the numbers stay in the markup where a template can write them and the CSS does the drawing. The bars grow through a scaleY transform with transform-origin at the bottom, and a per-bar delay through another custom property produces the stagger. The value label is a pseudo-element reading the data attribute with attr, and the gridlines are a repeating gradient on the chart background rather than extra elements.

The list markup keeps every label paired with its bar, and the chart works without JavaScript.

0
#css
#html
#bar chart
#chart
#data visualization
#animation
#dashboard