Skip to content

Pure CSS HTML interaction (shake) implementation using DOM and display order rules to trigger animation of a preceding element

Notifications You must be signed in to change notification settings

okozolin/CSS-shake-interaction

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CSS & HTML shake interaction - Flex trick

by: Orit Kozolin - FrontEnd / FullStack Developer Linkedin


CSS shake interaction

Purpose:

Activate animation where the triggering element should be displayed after the animated element.

The Problem:

With only pure HTML,CSS the triggering element should be placed as a parent or a sibling ,preceding the animated elemenet in the DOM tree. Which is the opposite of how we want it to be displayed in the page. Checkout the code to see how it's done.


Run

Open index.html in the browser.

How to see the effect

Hover over the blue bar, and watch the notification shake. That's the effect.

The trick

For this to work you need to do 2 steps in your code:

  1. HTML - Place the triggering element (the bar) first in the DOM. And, the triggered element (the notification) after (as siblings HTML elements, or as parent and child)

  2. CSS - Flip their display (rendering) using 'flex-direction: reverse-column' (This is the trick!).

That's it , you're done!

About

Pure CSS HTML interaction (shake) implementation using DOM and display order rules to trigger animation of a preceding element

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published