Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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

Auto Save

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 class="rotatingHeader">
	<h1>SPINNING TEXT</h1>
</div>



              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css2?family=Saira+Extra+Condensed:wght@800&family=Staatliches&display=swap');

body, html {
	width:100%;
	height:100%;
}

body {
	background:#12171b;
	display:flex;
	align-items:center;
	justify-content:center;
	flex-direction:column;
	overflow:hidden;
}

* {
	position:relative;
}

h1 {
	
}

.rotatingHeader {
	margin-bottom:2vw;

	width:fit-content;
	white-space:nowrap;

}

.rotatingHeader h1{
	font-family: 'Saira Extra Condensed', sans-serif;
	color:#444;
	font-size:100px;
	margin:0;
	padding:0;
	line-height:0.5;
	perspective:600px;
}

.rotatingHeader h1:nth-child(2) {
	color:#efefef;
}
              
            
!

JS

              
                const tl = gsap.timeline()

function initHeaders() {
	   //make a clone of the h1 tag
		let header = document.querySelector(".rotatingHeader")
		let original = header.querySelector("h1")
		let clone = original.cloneNode(true)
		header.appendChild(clone)
		gsap.set(clone, {yPercent:-100})
	
	
	   //split the text in original h1 and clone
		let originalSplit = SplitText.create(original, {type:"chars"})
		let cloneSplit = SplitText.create(clone, {type:"chars"})
		
		//global tween settings
		let duration = 0.4
		let stagger = {each:0.02, ease:"power2", from:"start"}

		//initial position of clones
		gsap.set(cloneSplit.chars, {rotationX:-90, opacity:0, transformOrigin:
"50% 50% -50"})
		
		
		//build animation
		tl.to(originalSplit.chars, {duration:duration, rotationX:90, transformOrigin:
"50% 50% -50", stagger:stagger})
		tl.to(originalSplit.chars, {duration:duration, opacity:0, stagger:stagger, ease:"power4.in"}, 0)
		
		tl.to(cloneSplit.chars, {duration:0.05, opacity:1, stagger:stagger}, 0.001)
		tl.to(cloneSplit.chars, {duration:duration, rotationX:0, stagger:stagger}, 0)

}


initHeaders()

GSDevTools.create({animation:tl})


// get a year of the world's best GSAP training for $49
// https://www.creativeCodingClub.com
// Make 2024 the year you master GSAP
              
            
!
999px

Console