DEV Community

Discussion on: Build your CSS loader with only one div — The Dots

Collapse
thumbone profile image
Bernd Wechner

Loved reading this thanks. Very nice. Doubt I'll ever make time for such artistic creation ;-) but that aside, what I'm a little rusty on (euphemism for clueless) is how this div is a CSS loader. I'm guessing you put the div on the page somehow, and on an event handler that's called when the whatever is complete you hide it?

Collapse
afif profile image
Temani Afif Author

A div, a span or any element can be your loader. We generally inject such element dynamically as a position:absolute element inside another element to create a loading effect and as you said a handler will later remove it.
You can also work by adding a class to the element that will trigger the creation of the loader inside a pseudo element then remove it when the work is done, ex: codepen.io/t_afif/pen/QWgaLmN

Some comments have been hidden by the post's author - find out more