Lifetime updates on every purchase Support replies within 24 hours Secure checkout via Gumroad 8,500+ sales since 2016

Quick start

Updated 1 min read 2 views
<section class="hero">…</section>
<script src="smooth-background.min.js"></script>
<script>
  new SmoothBackground('.hero', {
    colors: ['#F9BFBF', '#F9F4BF', '#BFC9F9', '#BFF9DB'],
    duration: '1.5s', // transition between two colors
    hold: '1s',       // pause on each color
  });
</script>

The first argument is an element or a CSS selector; for a selector, only the first match is used. To initialise many elements at once, use SmoothBackground.init():

SmoothBackground.init('.card', { colors: ['#fff', '#eee'] });
Was this article helpful?