HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URLs added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
Search for and use JavaScript packages from npm here. By selecting a package, an import
statement will be added to the top of the JavaScript editor for this package.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<link href="https://fonts.googleapis.com/css2?family=Corben:wght@700&display=swap" rel="stylesheet" />
<svg class="container" xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 800 400">
<defs>
<svg id="mask-text" xmlns="http://www.w3.org/2000/svg" width="100" height="100">
<linearGradient id="gradient" x1="0" x2="0" y1="0" y2="1" color-interpolation="sRGB" gradientUnits="objectBoundingBox">
<stop offset="0" stop-color="#000000" />
<stop offset=".86" stop-color="#000000" />
<stop offset="1" stop-color="#000000" stop-opacity="0" />
</linearGradient>
<rect width="100%" height="100%" fill="url(#gradient)" />
</svg>
<svg id="mask-blur" xmlns="http://www.w3.org/2000/svg" width="100" height="100">
<linearGradient id="gradient" x1="0" x2="0" y1="0" y2="1" color-interpolation="sRGB" gradientUnits="objectBoundingBox">
<stop offset="0" stop-color="#000000" stop-opacity="0" />
<stop offset=".2" stop-color="#000000" />
<stop offset=".55" stop-color="#000000" />
<stop offset="1" stop-color="#000000" stop-opacity="0" />
</linearGradient>
<rect width="100%" height="100%" fill="url(#gradient)" />
</svg>
<svg id="mask-displace" xmlns="http://www.w3.org/2000/svg" width="100" height="100">
<linearGradient id="gradient" x1="0" x2="0" y1="0" y2="1" color-interpolation="sRGB" gradientUnits="objectBoundingBox">
<stop offset="0" stop-color="rgb(127,0,127)" />
<stop offset="1" stop-color="rgb(127,0,127)" stop-opacity="0" />
</linearGradient>
<rect width="100%" height="100%" fill="url(#gradient)" />
</svg>
<filter id="dm-filter" x="0" y="0" width="100%" height="100%" color-interpolation-filters="sRGB" preserveAspectRatio="none">
<!-- Creating three color versions of the input text: -->
<feFlood flood-color="#FF50F6" flood-opacity="0.8" result="PINK" />
<feFlood flood-color="#43FFFF" flood-opacity="0.8" result="CYAN" />
<feFlood flood-color="#9C00FF" flood-opacity="0.8" result="VIOLET" />
<feComposite operator="in" in="PINK" in2="SourceAlpha" result="PINK_TEXT" />
<feComposite operator="in" in="CYAN" in2="SourceAlpha" result="CYAN_TEXT" />
<feComposite operator="in" in="VIOLET" in2="SourceAlpha" result="VIOLET_TEXT" />
<!-- Offsetting every instance of couloured text: -->
<feOffset in="PINK_TEXT" dx="-15" dy="5" result="PINK_TEXT_OFF" />
<feOffset in="CYAN_TEXT" dx="0" dy="7" result="CYAN_TEXT_OFF" />
<feOffset in="VIOLET_TEXT" dx="15" dy="3" result="VIOLET_TEXT_OFF" />
<!-- Blending the first two colors: -->
<feBlend in="PINK_TEXT_OFF" in2="CYAN_TEXT_OFF" result="BLEND_PC" mode="screen" />
<!-- Blending the third color: -->
<feBlend in="BLEND_PC" in2="VIOLET_TEXT_OFF" result="BLEND_ALL" mode="normal" />
<!-- Merging the original filter input (the text) and the 3 color versions -->
<feMerge result="MERGE_ALL">
<feMergeNode in="BLEND_ALL" />
<feMergeNode in="SourceGraphic" />
</feMerge>
<!-- A bitmap that will be the displacment map. Href value will be set by javascript, bcs. CORS and this way we can decide wether to feed a WebP image to newer browsers. -->
<feImage id="feimage-map" href="" data-map="https://assets.codepen.io/100347/fedm_vertical-map" width="100%" height="1936" x="0" y="-1536" result="MAP" preserveAspectRatio="none">
<animate attributeName="y" values="-1536;0;" dur="10s" repeatCount="1000" />
</feImage>
<!-- A linear gradient. We will use it as a mask to fade out the text at the bottom -->
<feImage href='#mask-text' x="0" y="0" width="100%" height="51%" result="MASK_TEXT" preserveAspectRatio="none" />
<!-- One more linear gradient. This one will be used to fade out the "drip" at the top. This way we achieve a smotth transition from the text to the blurry dripping part. -->
<feImage href='#mask-blur' x="0" y="35%" width="100%" height="60%" result="MASK_BLUR" preserveAspectRatio="none" />
<!-- And one last SVG image containing a linear gradient from rgba(128, 0, 128, 1) to rgba(128, 0, 128, 0). We will merge this with the animated displacement image, so that the displacement effect will increase gradually form zero at the top to its full extend at the end of the gradient. -->
<feImage href='#mask-displace' x="0" y="40%" width="100%" height="20%" result="MASK_DISPLACE" preserveAspectRatio="none" />
<!-- Merging the animated image and the gradient. -->
<feMerge result="MERGE_MASK">
<feMergeNode in="MAP" />
<feMergeNode in="MASK_DISPLACE" />
</feMerge>
<!-- Using the output of the merge to create a displacement map filter primitive: -->
<feDisplacementMap in="MERGE_ALL" in2="MERGE_MASK" result="DISPLACE_MERGE" scale="-300" xChannelSelector="R" yChannelSelector="B" />
<feGaussianBlur in="DISPLACE_MERGE" stdDeviation="6" result="BLUR_DISPLACE" />
<feComposite in2="MASK_BLUR" in="BLUR_DISPLACE" operator="in" result="COMP_DISPLACE" />
<feComposite in2="MASK_TEXT" in="SourceGraphic" operator="in" result="COMP_SOURCE" />
<feMerge result="MERGE">
<feMergeNode in="COMP_DISPLACE" />
<feMergeNode in="COMP_SOURCE" />
</feMerge>
</filter>
</defs>
<g class="displacement">
<svg width="100%" height="100%" viewBox="0 0 800 400">
<rect width="100%" height="100%" fill="transparent" />
<text class="corben" y="50%" x="50%" text-anchor="middle" letter-spacing="-.09em">
Jelly Drip
</text>
</svg>
</g>
</svg>
*,
*::before,
*::after {
box-sizing: border-box;
margin: 0;
padding: 0;
}
html {
height: 100%;
}
body {
margin: 0;
padding: 1.25em;
height: 100%;
color: white;
font: 0.85em -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
min-width: 320px;
}
.filter {
position: absolute;
top: 0;
left: -1;
width: 1px;
height: 1px;
visibility: hidden;
}
body {
position: relative;
overflow: hidden;
text-align: center;
background: linear-gradient(
0deg,
rgba(19, 0, 34, 0.3),
rgba(19, 0, 34, 0.9) 35%,
rgba(19, 0, 34, 1) 50%,
rgba(19, 0, 34, 0.9) 65%,
rgba(19, 0, 34, 0.3)
),
url(https://assets.codepen.io/100347/fedm_bgpattern-warped.svg) center no-repeat, rgb(19, 0, 34);
background-size: 100%;
display: flex;
}
.container {
position: relative;
width: 800px;
height: 400px;
margin: auto;
}
.displacement {
filter: url('#dm-filter');
}
.corben {
display: block;
position: relative;
margin: 0 auto;
padding: 0.5em;
top: 50%;
fill: white;
font: 120px/0.75 'Corben', sans-serif;
}
.infotext {
font: 0.8em/0.75 'Bungee', sans-serif;
}
const feImages = document.querySelectorAll('feImage');
webpSupported().then((supported) => {
const suffix = supported ? 'webp' : 'jpg';
for (let feImg of feImages) {
const href = feImg.getAttribute('href');
if (/^#/g.test(href)) {
const fragment = document.querySelector(href);
const fragmentString = encodeURIComponent(fragment.outerHTML);
feImg.setAttribute('href', `data:image/svg+xml;charset=utf-8,${fragmentString}`)
} else if (feImg.getAttribute('data-map')) {
const map = feImg.getAttribute('data-map');
fetch(`${map}.${suffix}`, {
method: 'GET',
headers: new Headers(),
mode: 'cors',
cache: 'default',
})
.then((response) => {
return response.blob();
})
.then((blob) => {
return URL.createObjectURL(blob);
})
.then((url) => {
feImg.setAttribute('href', url);
});
}
}
});
Also see: Tab Triggers