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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                .center
		p.swipe 
			span.sentence.sentence--show Do you not think so far ahead? Because I've been thinking about forever
			span.sentence I remember how I forget how you feel. How you were the first for me

a(href="http://nathan.tokyo" target="_blank").sig NATHAN.TOKYO
              
            
!

CSS

              
                $main: #EBE8E1;
$second: #333;
$back: #F0CF61;

$time: 1000ms;

.swipe{
	position: relative;
	text-align: center;
	height: 3em;

	.sentence{
		position: absolute;
		display: block;
		overflow: hidden;
		width: 100%;
		z-index: 1;
    color: transparent;
		.line-wrap{
			position: relative;
			display: block;
			width: 100%;
			color: transparent;
			transition: color 1ms;
			transition-delay: 500ms;
			&:nth-child(2){
				transition-delay: $time*4/6;
			}
			&:nth-child(3){
				transition-delay: $time*5/6;
			}
			&:after{
				content: '';
				position: absolute;
				width: 100%;
				height: 100%;
				top: 0;
				left: 0;
				background: $main;
				transform: translateX(-100%);
				transform-origin: 0% 50%;
			}
		}
		&--show{
			z-index: 2;
			.line-wrap{
				color: $second;
			}
			.line-wrap:after{
				transform: translateX(100%);
				transition: transform $time ease-in-out;
			}
			.line-wrap:nth-child(2):after{
				transition-delay: $time*1/6;
			}
			.line-wrap:nth-child(3):after{
				transition-delay: $time*2/6;
			}
		}
	}
}




body{
	background: $back;
	color: $second;
	font-family: 'Avenir', sans-serif;
	font-weight: 100;
	font-size: 5vw;
}

.center{
	position: absolute;
	top: 50%;
	left: 50%;
	width: 60vw;
	transform: translate3d(-50%,-50%,0);
}

.sig{
  position: fixed;
  bottom: 5px;
  right: 5px;
  text-decoration: none;
  font-size: 12px;
  font-weight: 800;
  font-family: sans-serif;
  color: rgba(0,0,0,0.4);
}
              
            
!

JS

              
                linePage();
cycleText();

function linePage(){

	var splitMe = $('.sentence');

	splitMe.each(function(index){

		var text = $(this).html();
		var output = '';

		//split all letters into spans
		for (var i = 0, len = text.length; i < len; i++) {
		  
		  	output += '<span data-index="'+i+'">' + text[i] + '</span>';
			
		}

		//put it in the html
		$(this).html(output);

		//check the offset of each letter to figure out where the line breaks
		var prev = 0;
		var parts = [];
		$(this).find('span').each(function(i){
			if ($(this).offset().top > prev){
				parts.push(i);
				prev = $(this).offset().top;
			}
		})

		parts.push(text.length);

		//create final 
		var finalOutput = ''

		parts.forEach(function(endPoint, i){
			if (endPoint > 0){
				finalOutput += '<span data-line="'+i+'" class="line-wrap"><span class="line-inner">' + text.substring(parts[i-1],parts[i]) + '</span></span>';
			}
		})

		$(this).html(finalOutput);
		$(this).addClass("lined");

	})

}

function cycleText(){

	setInterval(function(){

		$('.sentence').toggleClass('sentence--show');

	}, 4000)

  setTimeout(function(){
    $('.sentence').toggleClass('sentence--show'); 
  },1000)
  
}
              
            
!
999px

Console