Values on hover
04 of 23Where the wind blows from
Bars whose values show when you hover their slat, with a compass needle in the gutter turned by the data.
- hover CSS
- gutter Label
- data in style
The simple version
Bars whose value fades in when you hover their slat. The same structure with almost no styling: a good place to start your own.
How it’s built
This is the smallest interaction there is: no state, no handler, no JavaScript.
The slat draws a start Label for the day, a Bar to d.visits, and a Label at the same value holding a <span>.
The span starts at opacity: 0, and one line in the slat’s CSS brings it back:
.slat:hover .value > span { opacity: 1; }
Note that the fade is on the span inside the Label, never on the Label itself.
rhp moves a block with a transition of its own, and your transition on that block would replace it, so the Label would jump to each new value instead of travelling with its bar.
The gallery version adds:
- A compass needle turned by the data.
The needle in the start gutter is an ordinary element of the slat, not a block, so its
rotatecan come straight from the row’s wind direction. - A gust that fades in with the value, from the same
:hoverrule, so the whole slat reacts as one.