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.
<div class="relative w-screen h-screen">
<div class="absolute inset-0" id="slide-a" style="opacity:1">
<svg id="svg-a" class="relative w-full h-full">
<defs>
<filter id="ripple-filter">
<feImage width="0%" height="0%" result="rippleImage" id="fimg-a" />
<feDisplacementMap
id="displacement-map-a"
xChannelSelector="R"
yChannelSelector="G"
in="SourceGraphic"
in2="rippleImage"
result="displacementMap"
color-interpolation-filters="sRGB"
scale="0"
/>
<feComposite operator="in" in2="rippleImage"></feComposite>
</filter>
</defs>
<g id="logo">
<image
id="logo-image-a"
xlink:href="https://images.unsplash.com/photo-1521804906057-1df8fdb718b7?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1350&q=80"
preserveAspectRatio="xMinYMin slice"
class="w-full h-full"
/>
<image
id="logo-overlay-a"
xlink:href="https://images.unsplash.com/photo-1521804906057-1df8fdb718b7?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1350&q=80"
filter="url(#ripple-filter)"
preserveAspectRatio="xMinYMin slice"
class="w-full h-full"
/>
</g>
</svg>
<div class="absolute inset-0 flex items-center h-full w-full" id="title-a">
<div class="w-1/2 lg:w-1/4 ml-10 lg:ml-64">
<h1 class="text-3xl uppercase">deserunt mollit</h1>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua
</p>
<button class="bg-gray-800 text-white font-bold py-2 px-4 rounded mt-4">
Explore
</button>
</div>
</div>
</div>
</div>
<div class="absolute inset-0" id="slide-b" style="opacity:0">
<svg id="svg-b" class="relative w-full h-full">
<defs>
<filter id="ripple-filter">
<feImage width="0%" height="0%" result="rippleImage" id="fimg-b" />
<feDisplacementMap
id="displacement-map-b"
xChannelSelector="R"
yChannelSelector="G"
in="SourceGraphic"
in2="rippleImage"
result="displacementMap"
color-interpolation-filters="sRGB"
scale="0"
/>
<feComposite operator="in" in2="rippleImage"></feComposite>
</filter>
</defs>
<g id="logo">
<image
id="logo-image-b"
xlink:href="https://images.unsplash.com/photo-1541534741688-6078c6bfb5c5?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1349&q=80"
preserveAspectRatio="xMinYMin slice"
class="w-full h-full"
/>
<image
id="logo-overlay-b"
xlink:href="https://images.unsplash.com/photo-1541534741688-6078c6bfb5c5?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1349&q=80"
filter="url(#ripple-filter)"
preserveAspectRatio="xMinYMin slice"
class="w-full h-full"
/>
</g>
</svg>
<div class="absolute inset-0 flex items-center h-full w-full" id="title-b">
<div class="w-1/2 lg:w-1/4 ml-10 lg:ml-64">
<h1 class="text-3xl uppercase">occaecat cupidatat</h1>
<p>
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</p>
<button class="bg-gray-800 text-white font-bold py-2 px-4 rounded mt-4">
Explore
</button>
</div>
</div>
</div>
<header class="fixed inset-x-0 top-0 px-6" style="z-index:10">
<div class="flex h-16 justify-between border-b border-white items-center px-8">
<button class="w-12 h-12 flex items-center justify-center rounded-full">
<svg viewBox="0 0 500.03 500.03" xmlns="http://www.w3.org/2000/svg" class="w-8 h-8 text-white" fill="currentColor"><path d="M252.581 395.053c15.688 15.708 15.591 40.979 0 56.57l-35.28 35.28c-15.461 15.5-40.874 15.696-56.57 0l-147.61-147.61c-15.59-15.6-15.59-40.98 0-56.57l35.28-35.28c15.591-15.592 40.862-15.688 56.57 0zM19.068 377.737c-3.609-3.609-9.609-2.946-12.395 1.331-11.067 16.986-7.654 37.463 5.028 50.146l59.11 59.11c12.572 12.572 33.034 16.189 50.14 5.034 4.278-2.79 4.949-8.788 1.338-12.4zm257.773-209.024c-6.25-6.24-16.38-6.24-22.63 0l-85.5 85.5c-6.25 6.25-6.25 16.38 0 22.63l54.47 54.47c6.229 6.229 16.359 6.251 22.63 0l85.5-85.5c6.25-6.25 6.25-16.38 0-22.63zm204.132-46.442c3.612 3.612 9.613 2.939 12.402-1.341 11.146-17.11 7.485-37.577-5.054-50.117l-59.11-59.11C416.56-.939 396.096-4.423 379.088 6.654c-4.278 2.786-4.944 8.787-1.334 12.397zM339.291 13.123c-15.6-15.59-40.98-15.6-56.57 0l-35.28 35.28c-15.591 15.59-15.688 40.861 0 56.57l147.61 147.61c15.723 15.703 40.996 15.575 56.57 0l35.28-35.28c15.59-15.59 15.59-40.97 0-56.57z"/></svg>
</button>
<ul class="flex">
<li class="mr-10">
<a href="">Home</a>
</li>
<li class="mr-10">
<a href="">Services</a>
</li>
<li class="mr-10">
<a href="">Equipment</a>
</li>
</ul>
</div>
</header>
</div>
@import url("https://fonts.googleapis.com/css?family=Montserrat&display=swap");
html,
body {
height: 100%;
margin: 0;
overflow: hidden;
color: #fff;
font-family: "Montserrat", sans-serif;
}
// https://dribbble.com/shots/6887888-Sports-clothing-and-fashion-online-store
// https://codepen.io/osublake/pen/WQyBJb
let width;
let height;
const setA = (ele, settings)=>{
const el = document.getElementById(ele)
if(!el) return
Object.entries(settings).forEach(([key,val])=>{
el.setAttribute(key, val)
})
}
const onResize = () => {
const { innerWidth, innerHeight } = window;
width = innerWidth;
height = innerHeight;
setA("fimg-a", { x: width / 2, y: height / 2 });
setA("fimg-b", { x: width / 2, y: height / 2 });
};
onResize();
window.addEventListener("resize", onResize);
TimelineLite.prototype.wait = function(position) {
return this.set({}, {}, position);
};
var xlink = "http://www.w3.org/1999/xlink";
var imgUrl = "https://i.imgur.com/nQPodHo.png";
var feImage = document.querySelector("feImage");
let images = [
"https://images.unsplash.com/photo-1483721310020-03333e577078?ixlib=rb-1.2.1&auto=format&fit=crop&w=1400&q=80",
"https://images.unsplash.com/photo-1522898467493-49726bf28798?ixlib=rb-1.2.1&auto=format&fit=crop&w=1350&q=80",
"https://images.unsplash.com/photo-1521804906057-1df8fdb718b7?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1350&q=80",
"https://images.unsplash.com/photo-1541534741688-6078c6bfb5c5?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1349&q=80",
];
const setNextLoop = slides => {
const [a, b] = slides;
const [first, ...rest] = images;
images = [...rest, first];
setA(`logo-image-${a}`, { "xlink:href": first });
setA(`logo-overlay-${a}`, { "xlink:href": first });
loop([b, a]);
};
const loop = slides => {
const tl = new TimelineMax({ onComplete: () => setNextLoop(slides) });
tl.set("#fimg-a", {
attr: { x: width / 2, y: height / 2, width: "0", height: "0" }
})
.set("#fimg-b", {
attr: { x: width / 2, y: height / 2, width: "0", height: "0" }
})
.from("#displacement-map-a", 2, { attr: { scale: 1000 } }, 0)
.from("#displacement-map-b", 2, { attr: { scale: 1000 } }, 0)
.to(`#slide-${slides[0]}`, 3, { opacity: 0 }, 0)
.to(`#slide-${slides[1]}`, 3, { opacity: 1 }, 0)
.to(`#title-${slides[0]}`, 1, { y: -100, opacity: 0 }, 0)
.from(`#title-${slides[1]}`, 1, { y: 100, opacity: 0 }, 0.5)
.to(
"#fimg-a",
2,
{
attr: {
x: -width / 2,
y: -height / 2,
width: "200%",
height: "200%"
}
},
0
)
.to(
"#fimg-b",
2,
{
attr: {
x: -width / 2,
y: -height / 2,
width: "200%",
height: "200%"
}
},
0
)
.set(`#slide-${slides[0]}`, { zIndex: 3 }, 3)
.set(`#slide-${slides[1]}`, { zIndex: 5 }, 3)
.set(`#title-${slides[0]}`, { y: 0, opacity: 1 }, 3);
};
toBase64(imgUrl, function(data) {
feImage.setAttributeNS(xlink, "xlink:href", data);
loop(["a", "b"]);
});
function toBase64(url, callback) {
var img = new Image();
img.crossOrigin = "anonymous";
img.onload = function() {
var canvas = document.createElement("canvas");
var ctx = canvas.getContext("2d");
canvas.height = this.height;
canvas.width = this.width;
ctx.drawImage(this, 0, 0);
var dataURL = canvas.toDataURL("image/png");
callback(dataURL);
canvas = null;
};
img.src = url;
}
Also see: Tab Triggers