Skip to content

Instantly share code, notes, and snippets.

@CodeMyUI
Created February 12, 2018 05:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save CodeMyUI/770fc307ee4c11b44cd7ece5bf227dfb to your computer and use it in GitHub Desktop.
Save CodeMyUI/770fc307ee4c11b44cd7ece5bf227dfb to your computer and use it in GitHub Desktop.
letters effect
<ul class="text hidden">
<li>N</li>
<li class="ghost">T</li>
<li class="ghost">T</li>
<li>D</li>
<li class="ghost">A</li>
<li class="ghost">T</li>
<li class="ghost">A</li>
<li class="spaced">D</li>
<li class="ghost">e</li>
<li class="ghost">s</li>
<li class="ghost">i</li>
<li class="ghost">g</li>
<li class="ghost">n</li>
<li class="spaced">N</li>
<li class="ghost">e</li>
<li class="ghost">t</li>
<li class="ghost">w</li>
<li class="ghost">o</li>
<li class="ghost">r</li>
<li class="ghost">k</li>
</ul>
$(function() {
var text = $(".text");
$(window).scroll(function() {
var scroll = $(window).scrollTop();
if (scroll >= 200) {
text.removeClass("hidden");
} else {
text.addClass("hidden");
}
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js"></script>
@import url('https://fonts.googleapis.com/css?family=Muli:300,400,700');
* {
margin: 0;
padding: 0;
}
body {
background-color: #000;
height: 200vh;
font-family: 'Muli', sans-serif;
}
.text {
position: fixed;
top: 50%;
left: 50%;
transform: translateX(-50%) translateY(-50%);
list-style: none;
border-bottom: 0;
}
.text.hidden {
border-bottom: 1px solid #fff;
}
.text li {
display: inline-block;
float: left;
font-weight: 700;
font-size: 2em;
color: #fff;
opacity: 1;
transition: all 1.5s ease-in-out;
max-width: 2em;
}
.text.hidden li.spaced {
padding-left: 0;
}
.text li.spaced {
padding-left: 0.5em;
}
.text.hidden li.ghost {
opacity: 0;
max-width: 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment