Flip Text
Headline whose letters flip over in 3D one after another in a looping wave.
Preview and code
index.html
<!--
Ported to plain HTML/CSS/JS for OwnlyPlans from ObsidianUI (https://github.com/Atharvsinh-codez/ObsidianUI)
MIT License — Copyright (c) 2026 ObsidianUI
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED.
-->
<div class="op-flip-stage">
<div class="op-flip-text" data-text="Build something worth sharing" data-duration="2.2" data-delay="0" data-loop="true"></div>
</div>
styles.css
/* Ported from ObsidianUI (MIT License, Copyright (c) 2026 ObsidianUI) */
.op-flip-stage{min-height:320px;display:grid;place-items:center;background:#fafafa;color:#0a0a0a;font-family:Inter,system-ui,sans-serif;font-size:clamp(2rem,6vw,4.5rem);font-weight:700;letter-spacing:-.03em;text-align:center;padding:2rem}
.op-flip-text{display:inline-block;line-height:1;perspective:1000px}
.op-flip-text .word{display:inline-block;white-space:nowrap;transform-style:preserve-3d}
.op-flip-text .ws{display:inline-block}
.op-flip-char{display:inline-block;position:relative;transform-style:preserve-3d;color:inherit;-webkit-text-fill-color:transparent;height:1.2em;line-height:1.2em;vertical-align:middle;animation:op-flip var(--flip-duration,2.2s) var(--flip-delay,0s) var(--flip-iteration,infinite) ease}
.op-flip-char::before,.op-flip-char::after{color:inherit;-webkit-text-fill-color:currentColor;content:attr(data-char);position:absolute;top:50%;left:50%;height:100%;width:100%;display:flex;align-items:center;justify-content:center;backface-visibility:hidden;animation:op-fade var(--flip-duration,2.2s) var(--flip-delay,0s) var(--flip-iteration,infinite) ease}
.op-flip-char::after{transform:translate(-50%,-50%) translateZ(.6em)}
.op-flip-char::before{transform:translate(-50%,-50%) rotateX(-90deg) translateZ(.6em);opacity:0;--opacity:1}
@keyframes op-flip{0%{transform:rotateX(0deg)}25%,100%{transform:rotateX(90deg)}}
@keyframes op-fade{0%{opacity:1}30%,100%{opacity:var(--opacity,0)}}
script.js
document.querySelectorAll('.op-flip-text').forEach(function(el){
var text=el.dataset.text||el.textContent, dur=parseFloat(el.dataset.duration||2.2), delay=parseFloat(el.dataset.delay||0);
var loop=el.dataset.loop!=='false', together=el.dataset.together==='true', words=text.split(' '), total=text.length, idx=0;
el.textContent='';
words.forEach(function(w,wi){
var ws=document.createElement('span'); ws.className='word';
w.split('').forEach(function(c){
var s=document.createElement('span'); s.className='op-flip-char'; s.dataset.char=c; s.textContent=c;
var d=together?delay:Math.sin((idx/total)*(Math.PI/2))*(dur*.25)+delay;
s.style.setProperty('--flip-duration',dur+'s'); s.style.setProperty('--flip-delay',d+'s'); s.style.setProperty('--flip-iteration',loop?'infinite':'1');
ws.appendChild(s); idx++;
});
if(wi<words.length-1){var sp=document.createElement('span');sp.className='ws';sp.innerHTML=' ';ws.appendChild(sp);idx++;}
el.appendChild(ws);
});
});
About
Headline whose letters flip over in 3D one after another in a looping wave. Ported to plain HTML, CSS and JavaScript from ObsidianUI (github.com/Atharvsinh-codez/ObsidianUI), which is released under the MIT License. The original copyright notice is kept in the code.