Sarah's Lifestyle & Travel blog

/* This JS calculates the max-height of the card text. Allow code execution in Bricks Settings » Custom Code and execute this code element */ 

document.addEventListener('DOMContentLoaded', function () {
  // Get all the feature cards
  const featureCards = document.querySelectorAll('.brxw-feature-card-04');

  // Loop through all the cards and add event listeners
  featureCards.forEach(function (card) {
    const textElement = card.querySelector('.brxw-feature-card-04__text');

    if (textElement) {
      // Initially set max-height to 0 for the text elements
      textElement.style.maxHeight = '0';
      textElement.style.overflow = 'hidden';

      // Add hover event listeners
      card.addEventListener('mouseenter', function () {
        // Calculate the full height dynamically using scrollHeight
        const fullHeight = textElement.scrollHeight + 'px';
        textElement.style.maxHeight = fullHeight;
        textElement.style.marginTop = 'var(--brxw-content-gap)';
      });

      card.addEventListener('mouseleave', function () {
        // Reset the max-height to 0 when the hover ends
        textElement.style.maxHeight = '0';
        textElement.style.marginTop = '0';
      });
    }
  });
});

Latest Posts

Tempor aute voluptate eu est ut ad laboris est proident eu irure.

Instagram

This is a temporary excerpt used for demonstration purposes. It serves as a placeholder until actual content is provided.