Skip to content

Instantly share code, notes, and snippets.

@notwaldorf
Created June 6, 2022 18:19
Show Gist options
  • Save notwaldorf/4116bd36a8451d591bdff8e32674f8d2 to your computer and use it in GitHub Desktop.
Save notwaldorf/4116bd36a8451d591bdff8e32674f8d2 to your computer and use it in GitHub Desktop.
Elle does a typing
<h1 class="message-wrapper" style="text-align:center;white-space:pre-wrap;">
<span>Work more</span>
<ul class="message">
<li><span>effectively</span></li>
<li><span>inclusively</span></li>
<li><span>sustainably</span></li>
<li><span>intentionally</span></li>
</ul>
<br>
<span>Live more fully.</span>
</h1>
h1.message-wrapper {
white-space: nowrap !important;
}
h1.message-wrapper > span {
vertical-align: middle;
}
ul.message {
position: relative;
vertical-align: middle;
margin: 0;
padding: 0;
display: inline-block;
overflow: hidden;
line-height: 1.25em; /* this is the line-height of the h1 */
height: 1.25em; /* with some space for the ascenders/descenders */
}
ul.message li {
list-style: none;
text-align: left;
position: relative;
top: 0;
/* the 3s here are the length of the ::after animation */
animation: slideit calc(4 * 3s) steps(4) infinite;
}
@keyframes slideit {
100% { top: calc(-4 * 1.25em); }
}
ul.message li span {
display: inline-block;
position: relative;
line-height: 1.25em;
}
.message li span::after{
content: "";
position: absolute;
left: 0;
height: 100%;
width: 100%;
background: #fffff5;
border-left: 2px solid currentColor;
animation: typetytype 3s steps(10) infinite;
}
@keyframes typetytype {
40%, 60% { left: calc(100% + 10px); }
100% { left: 0; }
}
@notwaldorf
Copy link
Author

I changed whatever your h1 used to be to have a class, and some extra markup inside.

I also added a giant <style> block at the end of your index.html with these styles, BUT i think you can just add them at the end of whatever stylesheet you have that you edit normally

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment