Jump to content
Search Community

Data-lag not working for spans inside h1

Praneet Dixit test
Moderator Tag

Go to solution Solved by akapowl,

Recommended Posts

  • Solution

 

Hello @Praneet Dixit

 

This is probably a CSS issue, related to the spans being display: inline by default.

 

As it works 'properly' inside the flex container without the h1 wrapping the spans, one option would be to set the h1 to display: flex too.

 

But probably it would be safer to just set the spans to something like display: inline-block instead.

 

See the Pen RwMGNGy by akapowl (@akapowl) on CodePen

Link to comment
Share on other sites

 

I'm on Windows and I can see the gradient with both approaches just fine in every major browser. My best guess is that you are viewing this on Safari, which does have quite a lot of quirks with regard to scenarios like these ( gradients on text or in general ) if I recall correctly.

 

This really is more of a general CSS / browser related issue and not a problem with regard to GSAP.

 

27 minutes ago, Praneet Dixit said:

can we use another approach for solving this issue?

 

You have to go with however browsers work - and for being able to transform spans (which is what the data-lag essentially does behind the scenes) you will need to change their display property because tranforms don't work on inline elements (unless they are in a flex container apparently).

 

So if you need the gradient text to be working across browsers 100%, you will need to find a setup that allows for that with keeping in mind that you also need transforms to be working on your elements, which I can not work out for you, I'm afraid.

 

Here's a pen just showing that transforms don't work on inline elements.

 

See the Pen dympovr by akapowl (@akapowl) on CodePen

 

  • Like 2
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...