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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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.

Editor Settings

Code Indentation

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

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

            
              <ul class="scroll">
	<li class="scroll-item item_01 is-active" id="item-01">
		Item 01
	</li>
	<li class="scroll-item item_02" id="item-02">
		Item 02
	</li>
	<li class="scroll-item item_03" id="item-03">
		Item 03
	</li>
	<li class="scroll-item item_04" id="item-04">
		Item 04
	</li>
	<li class="scroll-item item_05" id="item-05">
		Item 05
	</li>
</ul>
            
          
!

CSS

            
              .scroll{
	display: flex;
	flex-direction: column;
	align-items: center;
}

.scroll-item{
	width: 100%;
	height: 720px;
	display: flex;
	justify-content: center;
	align-items: center;
	text-align: center;
	text-transform: uppercase;
	font-size: 16px;
	color: #fff;
	transition: 0.3s;
}

.scroll-item.item_01{
	background-color: #0a759e;
}

.scroll-item.item_02{
	background-color: #00a1ff;
}

.scroll-item.item_03{
	background-color: #ffd400;
}

.scroll-item.item_04{
	background-color: #000;
}

.scroll-item.item_05{
	background-color: #ff2f00;
}

.scroll-item.is-active{
	background-color: #0e8824;
}
            
          
!

JS

            
              var alturaTela = jQuery(window).height(); // Pega altura da tela
var ajuste = alturaTela / 2; // O elemento vai ativar ao chegar no meio da tela, pode ser um numero customizado também
jQuery(window).scroll(function(event){ // Detecta o scroll do mouse
	jQuery('.scroll-item').each(function(i){ // Faz um foreach com os elementos que deseja identificar
		var status = jQuery(this).hasClass('is-active'); // Usado para identificar se o elemento está ativo.
		if (!status) { // Se o elemento NÃO ! estiver ativo
			var elementoTop = jQuery(this).offset().top + ajuste; // Pega a posição do elemento no eixo Y (vertical) e soma com o ajuste
			var elementoBottom = elementoTop + jQuery(this).outerHeight(); // Soma a posição do elemento com a altura total dele
			var viewportTop = jQuery(window).scrollTop(); // Pega a posição atual do scroll no eixo Y (vertical)
			var viewportBottom = viewportTop + alturaTela; // Soma a posição atual do scroll com a altura da tela.

			if (elementoBottom > viewportTop && elementoTop < viewportBottom) {
				jQuery('.scroll-item').removeClass('is-active'); // Remove a classe de todos os elementos
				jQuery(this).addClass('is-active'); // Adiciona a classe ao elemento atual
		    }
		}
	})
});
            
          
!
999px

Console