<!-- Hint: Try dragging the resize handle at the bottom-right corner of the text -->
<div>str<i>e</i>ss</div>
/*
* 13 January 2021
* CSS Stretchy Heading
* Made in response to my anxiety about the upcoming viva exam (14-15 Jan)
*/
/* === relevant portion === */
:root {
font-family: "Montserrat", "Arial", sans-serif;
font-size: 7em;
--color: #fff;
--color-accent-1: hsl(50, 100%, 79%);
--color-accent-2: hsl(340, 100%, 39%);
}
div {
position: relative;
filter: drop-shadow(0.15em 0.1em 0.3em var(--color-accent-2));
color: var(--color);
width: min(70%, 1000px);
min-width: fit-content;
max-width: calc(100% - 0.5em);
transition: all ease-out 100ms;
padding: 0 0.3em;
font-weight: 800;
/* touch-action: none; */
text-transform: uppercase;
white-space: nowrap;
resize: horizontal;
overflow: hidden;
opacity: 0;
animation: fade-in ease-out 300ms 1.2s forwards;
display: flex;
}
i {
/* === stretch up! */
flex: 1;
/* === type geometry */
--offset-left: 0.1ch;
--offset-top: 0.396ch;
--offset-top-center: 0.79ch;
--offset-bottom: 0.36ch;
--offset-right: 0.18ch;
--offset-right-center: 0.28ch;
--letter-height: 1.02ch;
--letter-pillar-width: 0.28ch;
--letter-pillar-height: 0.24ch;
--paint: linear-gradient(var(--color) 0 0);
background-image: var(--paint), var(--paint), var(--paint), var(--paint);
background-position:
/* the "|" of "E" */ var(--offset-left) var(--offset-top),
/* the "ˉ" of "E" */ var(--offset-left) var(--offset-top),
/* the "_" of "E" */ left var(--offset-left) bottom var(--offset-bottom),
/* the "-" of "E" */ var(--offset-left) var(--offset-top-center);
background-size: var(--letter-pillar-width) var(--letter-height),
calc(100% - var(--offset-right)) var(--letter-pillar-height),
calc(100% - var(--offset-right)) var(--letter-pillar-height),
calc(100% - var(--offset-right-center)) var(--letter-pillar-height);
background-repeat: no-repeat;
font-style: normal;
color: #fff0;
opacity: 0.98;
}
/* === to make things look pretty === */
* {
box-sizing: border-box;
padding: 0;
margin: 0;
}
html,
body {
width: 100%;
height: 100%;
background-color: #000;
}
html::before {
content: "";
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 100%;
display: block;
background-image: linear-gradient(
-45deg,
var(--color-accent-1),
var(--color-accent-2)
);
}
body {
display: flex;
place-items: center;
justify-content: center;
}
@keyframes fade-in {
to {
opacity: 1;
}
}
::selection {
color: var(--color);
background-color: var(--color-accent-2);
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.