Jump to content
Search Community

Multiline SplitText element with hard line break

doughamlin test
Moderator Tag

Recommended Posts

Is it possible to have a <span> or other inline element  with a hard line break (<br> element) break correctly inside a SplitText element? For example, to have "ipsum" and "dolar" break correctly in my Codepen. I thought this was the answer, but the nestedLinesSplit function there didn't do the job.

See the Pen LYpYvrJ by doughamlin (@doughamlin) on CodePen

Link to comment
Share on other sites

Hey doughamlin and welcome. Thanks for being a Business Green member! We couldn't do what we do without people like you. 

 

In the limitations section of the SplitText documentation it says:

Quote

SplitText only recognizes raw text and <br> tags, not child elements like <strong> or <em> elements

 

However, if you know that there's going to be a line break there, why use SplitText? Why not just put each line into its own div instead?

<div class="myClass">Lorem <strong>ipsum</strong></div>
<div class="myClass"><strong>dolar</strong> sit amet</div>

Side note: There's not good reason to use <br> tags in most cases. 

  • 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.
×
×
  • Create New...