Jump to content
Search Community

SplitText plugin can't divide paragraphs

Zhiyi Zeng test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

I'm trying SplitText plugin in official examples provided in Codepen. However, I don't know how to divide paragraphs. I mean, let's say there are paragraph One and paragraph Two, divided by <p></p> , if using SplitText plugin, <p> tag will not exist any more and paragraph one && two become one paragraph. How to keep two paragraphs divided while using SplitText?

 

Here is a simple demo to illustrate more:

```html
# before using SplitText
<div class="container">
  <p class="paragraph1">
    Hello, Gsap!
  </p>
  <p class="paragraph2">
    Hello, SplitText!
  </p>
</div>

# after using SplitText
<div class="container">
	<span>Hello</span>
	<span>Gsap</span>
	<span>Hello</span>
	<span>SplitText</span>
</div>

# What I want to get
<div class="container">
	<p class="paragraph1">
      <span>Hello</span>
      <span>Gsap</span>
	</p>	
	<p class="paragraph2">
      <span>Hello</span>
      <span>SplitText</span>
	</p>
</div>

```

 

Link to comment
Share on other sites

3 minutes ago, mikel said:

Hey @Zhiyi Zeng,

 

Does this pen help you?
 

 

 

 

Happy tweening ...

Mikel

Yes, it helps a lot! Thanks.  It's an elegant way to do so.

 

But, I'm wondering if there is any way for SplitText to keep paragraphs what they are. I have dozens of, but uncertain numbers of paragraphs in every passage, with some css files included. Such a solution would still wipe out all css styles. 

 

Best regards,

Zhiyi

 

 

Link to comment
Share on other sites

17 minutes ago, Zhiyi Zeng said:

SplitText plugin won't wipe out css styles(like font color), but in my computer, it shows otherwise.

 

What do you mean by that? Please give a CodePen example.

 

And: Please do not use the total quote to answer.
Either mark a position partially or use the button 'I'll Answer This' (bottom left).

 

Best regards

Mikel

 

 

Link to comment
Share on other sites

7 minutes ago, mikel said:

And: Please do not use the total quote to answer.
Either mark a position partially or use the button 'I'll Answer This' (bottom left).

OK, I won't do that anymore.

 

 

7 minutes ago, mikel said:

What do you mean by that? Please give a CodePen example.

In your first CodePen example, I changed 

<div class="quote quoteONE">SplitText makes it easy to break apart the text in an HTML element ... </div>

to 

<div class="quote quoteONE">SplitText makes <span style="color: red">it easy</span> to break apart the text in an HTML element ... </div>

"it easy" will be red. However, in my computer, the color won't change.

 

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