Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
TBWA-NY

Splittext breaks on inline elements

Recommended Posts

Splittext will sometimes split lines in odd ways, leaving single words by themselves.


Has anyone else had experience with this?

I have seen other posts suggesting to add letter-spacing etc.. which may fix it at a certain container width, but it will still do it at other widths.

 

 

Are nested inline elements supported if splitting by lines?

The documentation says no, but the workaround that is suggested doesn't seem to work either.

See the Pen ZdLybq by trobie (@trobie) on CodePen

Link to comment
Share on other sites

Hi @TBWA-NY,

 

Welcome to the GreenSock Forum.

 

In your text an <a> tag goes beyond the line to the next one.

 

No optimal solution, but it solves the problem:


<a>that</a> <a>each</a>


Happy tweening ...

Mikel

 

  • Like 3
Link to comment
Share on other sites

It appears you can also solve the trailing issue by setting <a> to inline-block but it forces it all on one line which may not be optimal.

 

See the Pen XLpaLa by Visual-Q (@Visual-Q) on CodePen

  • Like 2
Link to comment
Share on other sites

Thank you for the replies!


The odd thing is that on the site I am developing, the split occurred in an instance where there is only one word wrapped with an inline tag.
I got it to break in the odd way once or twice with this configuration in a pen, but it would not do it reliably. (sometimes break, then not).
So I did it with two words since it would always break. 

I am going to see if I can replicate the exact issue in a pen.

Link to comment
Share on other sites

Found the issue. 

 

I was preemptively setting overflow:hidden on the generated line divs without using a specific linesClass

This must somehow effect the calculation of what text is on what lines. I updated my pen to show that.

Bug of my own making. Easy to see it doesn't occur if you disable that style.

 

Thanks again guys for taking a look.

  • Like 3
Link to comment
Share on other sites

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.
×