<div class="st">
<i class="decorator full"></i>
<span class="w full js-w1">
<span class="l">S</span>trange<span class="l">r</span>
</span>
<i class="decorator"></i>
<span class="w w-2 js-w2">Things</span>
<i class="decorator"></i>
</div>
<input class="input js-txt" value="Stranger Things" placeholder="Two Words" />
* {
margin: 0;
padding: 0;
position: relative;
box-sizing: border-box;
}
html {
background-color: #110809;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
}
body {
height: 100%;
display: flex;
align-items: center;
justify-content: center;
flex: 0 1;
}
.st {
text-align: center;
flex: 0 1 auto;
display: flex;
flex-wrap: wrap;
font-family: "Cochin";
font-size: 5em;
font-weight: 600;
line-height: 1;
text-transform: uppercase;
color: transparent;
-webkit-text-stroke: 2px red;
filter: drop-shadow(0 0 15px rgba(255,0,0,1));
}
.l {
font-size: 1.4em;
vertical-align: -.175em;
margin-top: -.2em;
}
.full {
flex: 1 0 100%;
}
.w {
white-space: nowrap;
&-2 {
margin: 0 .1em;
margin-top: -.4em;
}
}
.decorator {
height: .1em;
border: 2px solid red;
flex: 1 0 auto;
}
.input {
position: absolute;
bottom: 2em;
text-align: center;
font: inherit;
appearance: none;
color: red;
background-color: transparent;
border: 2px dotted transparent;
border-bottom-color: currentColor;
opacity: .75;
&:focus {
opacity: 1;
outline: none;
}
}
// Enter your words here!
// Caveats: only two words, and the first word should be longer than the second.
const upsideDown = (words) => {
// Find the placeholders
let wordBuckets = [
document.querySelector('.js-w1'),
document.querySelector('.js-w2')
];
// Set up our words
let w1 = words.split(' ')[0] || 'Stranger',
w2 = words.split(' ')[1] || 'Things';
// Create an array from the first word
w1 = w1.split('');
// Grab the first and last letters of the first word
let l1 = w1[0],
l2 = w1[w1.length - 1];
// Remove the first and last letter from the first word
w1.shift();
w1.pop();
w1 = [
l1,
w1.join(''),
l2
];
wordBuckets[0].innerHTML = `<span class="l">${w1[0]}</span>${w1[1]}<span class="l">${w1[2]}</span>`
wordBuckets[1].innerHTML = `${w2}`;
}
let input = document.querySelector('.js-txt');
input.addEventListener('keyup', (e) => {
upsideDown(input.value);
});
As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.
Also see: Tab Triggers