Jump to content
Search Community

SplitText creating multiple nested divs

Nightshift

Go to solution Solved by PointC,

Recommended Posts

Posted

I have some very simple code with SplitText:

 

  document.fonts.ready.then(() => {
    const texts = document.querySelectorAll("[text-animation]");

    if (!texts) return;

    let splitText;

    function runSplit() {
      splitText = new SplitText("[text-animation]", {
        types: "lines",
        linesClass: "line",
      });
    }

    runSplit();
    
  });

 

For some reason, SplitText seems to be creating multiple nested ".line" divs, I've also noticed the same behaviour when using words. The only CSS applied to the text is color and font size.

 

Any idea on why this may be happening?

 

 

Screenshot 2025-01-13 at 10.04.06 a.m..png

  • Solution
Posted

You'd want 

type: "lines" 

in the config. You currently have "types" so it looks like SplitText is back to the default of characters, words and lines.

 

Happy tweening.

:)

 

  • Like 3

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...