Jump to content
Search Community

Splitting lines with Split Text that nested long <b> bold text without weirdly breaking the line

Reksa Andhika test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

Please help, I have read the docs, it's possible but it will make the tag duplicate to make the good breaking line, and that's okay for me because I don't have "id" on nested splittext, only <b> or <strong>, so duplicating this will be okay. I have tried all property existed but not working, also already trying adding <b> display: line-block;

 

The result that I want:
image.png.2137eab4172b68a5d7d69ce924f2e523.png

 

The result I got with splittext:

image.png.2d5577d9d59e0836879116835d395266.png

Thank you.

See the Pen qBLOgoL by reksaandhika (@reksaandhika) on CodePen

Link to comment
Share on other sites

  • Solution

Hi @Reksa Andhika. From the docs: 

Quote

Splitting nested elements by "lines" is not supported 

It's much more complex (or in some cases impossible) because it'd actually require creating entirely new nesting based on wrapping. The <strong> element, for example, might spill onto multiple PARTIAL lines, so how could two different line <div>s get wrapped around a single <strong>? And if it broke that <strong> into multiple ones, that could mess with your CSS. Imagine you had a border on that <strong>...uh oh. For example, try to recreate this by restructuring things so that there's a <div> around each line (but keep the formatting exactly the way it looks here): 

See the Pen MWZaMgG?editors=0110 by GreenSock (@GreenSock) on CodePen

 

That being said, I took a crack at improving the helper function: 

See the Pen zYyvVeY?editors=0010 by GreenSock (@GreenSock) on CodePen

 

Does that help? 

  • Like 3
Link to comment
Share on other sites

The function is working only when have one <p> @GreenSock

when more than <p> it's duplicating line inside line, like:

<div class="line">
  <div class="line">
    Text
  </div>
</div>

 

I remove this code, and it's working better, why do we need to this code anyway in your function?

if (target.length > 1) {
  for (i = 0; i < target.length; i++) {
    split.lines = split.lines.concat(nestedLinesSplit(target[i], vars).lines);
  }
}

 

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