Issue: Unable to Implement Animated Gradient Background in Hero Section (Similar to Calendly's Website)

Hello Divhunt team,

I’ve been trying to implement an animated background effect in my hero section similar to what Calendly uses on their website (https://calendly.com/), but I’ve encountered multiple roadblocks despite trying several different approaches.

What I’m trying to achieve:

  • A subtle, animated background with moving blue and purple gradient shapes/blobs in the hero section
  • Similar to the flowing background effect seen on Calendly’s homepage
  • The effect should appear behind the hero content without interfering with it

What I’ve tried so far (all unsuccessful):

  1. Embed Component Method
    First, I tried adding an embed component to the hero section with this code:
<style>
  .animated-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(-45deg, #6a5acd, #00bfff, #ff69b4, #00fa9a);
    background-size: 400% 400%;
    animation: gradientMove 15s ease infinite;
    z-index: -1;
  }

  @keyframes gradientMove {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
  }
</style>

<div class="animated-bg"></div>

Result: The code appeared in the embed component but had no effect on the site.

  1. Custom Code Section Method
    Next, I tried adding code to Site Settings > Custom Code in both Head End and Body Start sections:

In Head End:

<style>
@keyframes gradientBG {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.animated-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  background: linear-gradient(-45deg, rgba(0, 119, 255, 0.7), rgba(143, 0, 255, 0.7), rgba(0, 194, 255, 0.7));
  background-size: 400% 400%;
  animation: gradientBG 15s ease infinite;
}
</style>

In Body Start:

<script>
window.addEventListener('load', function() {
  const heroSection = document.querySelector('section');
  
  if (heroSection) {
    heroSection.classList.add('hero-section');
    
    const animatedBg = document.createElement('div');
    animatedBg.className = 'animated-bg';
    
    heroSection.insertBefore(animatedBg, heroSection.firstChild);
  }
});
</script>

Result: Nothing appeared in the hero section.

  1. Animated Blobs Method
    I then tried creating animated, blurred shapes to mimic Calendly’s effect:
<style>
.blob-blue {
  position: absolute;
  top: -10%;
  right: -10%;
  width: 60%;
  height: 60%;
  background-color: #0077ff;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.7;
  animation: moveBlob1 30s ease-in-out infinite;
  z-index: -1;
}

.blob-purple {
  position: absolute;
  bottom: -20%;
  left: -10%;
  width: 70%;
  height: 70%;
  background-color: #8f00ff;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.6;
  animation: moveBlob2 35s ease-in-out infinite;
  z-index: -1;
}

@keyframes moveBlob1 {
  0% { transform: translate(0, 0); }
  50% { transform: translate(50px, -30px); }
  100% { transform: translate(0, 0); }
}

@keyframes moveBlob2 {
  0% { transform: translate(0, 0); }
  50% { transform: translate(-50px, 50px); }
  100% { transform: translate(0, 0); }
}
</style>

Result: Again, nothing showed up.

  1. Simple Test Case
    To troubleshoot, I tried a very simple test case:
<style>
#animation-test {
  position: fixed;
  top: 10px;
  left: 10px;
  width: 30px;
  height: 30px;
  border: 2px solid black;
  z-index: 9999;
  animation: testAnimation 3s infinite;
}

@keyframes testAnimation {
  0% { background-color: red; }
  50% { background-color: blue; }
  100% { background-color: red; }
}
</style>

With JavaScript:

<script>
document.addEventListener('DOMContentLoaded', function() {
  var test = document.createElement('div');
  test.id = 'animation-test';
  document.body.appendChild(test);
});
</script>

Result: Interestingly, the test square DOES appear and animate correctly, showing that basic animations can work.

  1. Simple Blob Test
    I then tried a single, simple blob alongside the test square:
.simple-blob {
  position: fixed;
  top: 50px;
  left: 50px;
  width: 200px;
  height: 200px;
  background-color: #0077ff;
  border-radius: 50%;
  filter: blur(30px);
  opacity: 0.7;
  z-index: 9998;
}

Result: The blob briefly appeared but was static (no animation) and then disappeared when implementing more complex solutions.

Important note:
I was able to implement this exact same effect in just a few minutes using a standard IDE and web development tools. The CSS/JS code itself works perfectly in regular environments, so the issue seems to be specifically with how Divhunt processes or restricts custom code and animations.

Questions for the Divhunt team:

  1. Is there a recommended way to create animated background effects in Divhunt?
  2. Are there specific limitations on CSS animations or JavaScript DOM manipulation I should be aware of?
  3. Is there a native Divhunt component or feature I could use to achieve this effect?
  4. Could there be a specific setting in my project that’s preventing these animations from working?

Any guidance would be greatly appreciated as this effect is quite important for my project’s aesthetics.

Thank you!

I’ll take another look when I get home, but I believe I solved something similar to this (keyframing at least) by assigning the style of the background to a div background-color, but putting the keyframes in a hidden embed within the body of the page. That was only for an animating background gradient, though, but I’ll see if that page is still there and how I handled it.

Ok, I’ve made this up (Pubble | Testblob) if it’s what you’re after, here’s the process.

I’m just talking about the blobs here, not the gradient background.

You can see my structure in the image. I created a DIV as a container and inside I placed three embeds. Two for the ‘blobs’ or SVG shapes, and the last to control the keyframes for them.

The two ‘blob’ embeds have the structural CSS applied to their ‘self’. The animations (style with keyframes) are done within the ‘Move Animations’ embed.

Obviously make sure the keyframes are named how you’re calling them in the CSS. Finally (and this isn’t within the CSS on my image) I applied a mix bending mode to them - in this case it was multiply.

I hope this helps

1 Like

Thank you for your assistance.
Your example was extremely helpful and very well put together!

No problem at all! Glad I could help