Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div id="textDiv">
plain text
</div>


<div id="svgDiv">
<svg version="1.1" id="theSVG" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
	 width="200px" height="200px" viewBox="0 0 200 200" enable-background="new 0 0 200 200" xml:space="preserve">
<rect x="0" y="0" fill="#333" width="200" height="200"/>
<text transform="matrix(1 0 0 1 13.6377 111.9707)" >SVG Text</text>
</svg>

</div>

<div id="svgTextDirect">
<svg version="1.1" id="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
	 width="200px" height="200px" viewBox="0 0 200 200" enable-background="new 0 0 200 200" xml:space="preserve">
<rect x="0" y="0" fill="#333" width="200" height="200"/>
<text id ="myText" transform="matrix(1 0 0 1 13.6377 111.9707)" >SVG Text</text>
</svg>
<p>splittext = id of the text element</p>
</div>


<div id="svgDivStatic">
<svg version="1.1" id="theSVGStatic" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
	 width="200px" height="200px" viewBox="0 0 200 200" enable-background="new 0 0 200 200" xml:space="preserve">
<rect x="0" y="0" fill="#333" width="200" height="200"/>
<text transform="matrix(1 0 0 1 13.6377 111.9707)" >SVG Text</text>
</svg>
<p>static svg</p>
</div>

<div class="problem">
<p>1. plain text works as expected</p>
<p>2.The second example uses the parent div of the svg for the split text. It animates the text, but I lose the background rectangle, the text now moves to the top left position and it no longer respects the yellow fill color. This is also problematic because it will grab all text in the SVG if it has more than one text area.</p>
<p>3. I tried using an ID on the text element itself. The console shows the individual divs, but looks like they have no size?</p>
<p>4. The SVG should like like this static version: black rectangle with yellow text</p>
</div>
              
            
!

CSS

              
                #svgDiv, #textDiv, #svgDivStatic, #svgTextDirect {
	width: 200px;
	height: 200px;
	position: absolute;
	top: 30px;
	font-family: Helvetica, Arial, sans-serif;
	}

#svgDiv, #svgDivStatic, #svgTextDirect  {
	font-size: 39px;
	fill:yellow;
}

#svgDiv{
	left:220px;
}
#svgTextDirect {
	left:430px;
}

#svgDivStatic {
	left: 640px;
}


#textDiv{
	left: 10px;
	background: green;
	line-height: 200px;
	text-align: center;
	font-size: 36px;
	color: white;
}


p {
	font-size: 18px;
}

.problem {
	position: absolute;
	top:300px;
	max-width:600px;
}
              
            
!

JS

              
                var plainText = document.getElementById("textDiv");
	svgParent = document.getElementById("svgDiv");
	myText = document.getElementById("myText");
	splitText = new SplitText([plainText, svgParent, myText], {type:"chars", position: "absolute"});
	letters = splitText.chars;
	console.log(myText);
	
	tl = new TimelineLite({delay:1});
	tl.staggerFrom(letters, .7, {opacity:0, scale:0}, .05);
              
            
!
999px

Console