Jump to content
Search Community

GSAP splittext div's auto width

niiku23 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

Hi,

 

I am using GSAP Splittext to split a DIV (with auto width set in css) full of copy onto lines. I would like the subsequent DIVs that Splittext creates to auto size to the widths of the copy lines contained within them. I thought split text does this automatically but all of the divs that are made appear to be the same width as the widest piece of copy. Grateful for any help?

 

Thanks,

 

Nick

 

JS:

var cta_text_1 = document.getElementById("cta");
var split_cta_text_1 = new SplitText(cta_text_1, {type:"lines", linesClass:"textLine++"});

 

CSS:

.cta{
  position:absolute;
  font-size: 18px;
  text-align: center;
  height:auto;
  width:auto;
  left:0px;
  top:0px;
  color: #fff;
 border: 1px solid #999;
}

.textLine1 { 
  width:auto;
  border: 1px solid #7f7f7f;
}

.textLine2 { 
  width:auto;
  border: 1px solid #7f7f7f;
}

 

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