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="container1 ">
<div class="curtain1">
<div class="ratio-keeper">
<div class="video-one"></div>
<div class="wrap embed-youtube ">
<div class="video embed-youtube " data-id="djV11Xbc914">
</div>
<button class="playa embed-youtube-play iframe" type="button" aria-label="Open"></button>
</div>
</div>
<div class="exit"></div>
</div>
</div>
<div class="container2 hide">
<div class="container3 ">
<div class="container ">
<div class="curtain">
<div class="ratio-keeper">
<div class="video-two"></div>
<div class=" embed-youtube">
<div class="video embed-youtube" data-id="djV11Xbc914">
</div>
<button class="playb embed-youtube-play" type="button" aria-label="Open"></button>
</div>
</div>
</div>
<div class="curtain">
<div class="ratio-keeper">
<div class="video-three"></div>
<div class=" embed-youtube">
<div class="video embed-youtube" data-id="djV11Xbc914">
</div>
<button class="playc embed-youtube-play" type="button" aria-label="Open"></button>
</div>
</div>
</div>
<div class="curtain">
<div class="ratio-keeper">
<div class="video-four"></div>
<div class="embed-youtube">
<div class="video embed-youtube" data-id="djV11Xbc914">
</div>
<button class="playd embed-youtube-play" type="button" aria-label="Open"></button>
</div>
</div>
</div>
<div class="curtain">
<div class="ratio-keeper">
<div class="video-five"></div>
<div class="embed-youtube">
<div class="video embed-youtube" data-id="djV11Xbc914">
</div>
<button class="playe embed-youtube-play" type="button" aria-label="Open"></button>
</div>
</div>
</div>
<div class="curtain">
<div class="ratio-keeper">
<div class="video-six"></div>
<div class="embed-youtube">
<div class="video embed-youtube" data-id="djV11Xbc914">
</div>
<button class="playf embed-youtube-play" type="button" aria-label="Open"></button>
</div>
</div>
</div>
</div>
</div>
html,
body {
height: 100%;
margin: 0;
padding: 0;
}
body {
background: #302b63;
}
.embed-youtube.active .embed-youtube-play {
display: none;
}
.container1 {
position: absolute;
left: 0;
right: 0;
min-height: 100%;
min-width: 255px;
display: flex;
padding: 8px 8px;
}
.curtain1 {
flex: 1 0 0;
margin: auto;
max-width: 640px;
border: 21px solid;
border-radius: 12px;
border-color: #000 #101010 #000 #101010;
position: relative;
}
.curtain1::before {
content: "";
position: absolute;
top: -2px;
left: -2px;
right: -2px;
bottom: -2px;
background: radial-gradient(circle, transparent 0% 35%, #0a0a0a 35%);
border: 1px solid;
border-color: #000 #101010 #000 #101010;
}
.curtain1::after {
content: "";
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 0;
outline: 1px solid #f91f6e;
pointer-events: none;
}
.curtain.slide::after {
outline: 1px solid #0059dd;
transition: outline 2s ease-in;
/* add this */
/*background-image: none;*/
}
.video-one {
position: absolute;
height: 100%;
width: 100%;
top: 0;
transition: all 8s ease-in 0s;
transition-delay: 300ms;
background: linear-gradient(
45deg,
#0000 7px,
rgb(113, 121, 126) 0 7.5px,
#0000 0 10px
),
linear-gradient(-45deg, #0000 7px, rgb(113, 121, 126) 0 7.5px, #0000 0 10px),
url(https://i.imgur.com/ig4UO7B.jpg);
background-position: 0 0, 0 0, 0 0;
background-size: 10px 10px, 10px 10px, cover;
background-repeat: repeat, repeat, no-repeat;
filter: drop-shadow(0 0 5px #000);
z-index: 1;
}
.curtain1.slide .video-one {
/* transform: translateY(-100%);*/
animation: fadeOut 2s ease-in 700ms forwards;
}
@keyframes fadeOut {
to {
opacity: 0;
}
}
.container {
position: absolute;
left: 0;
right: 0;
min-height: 100%;
padding: 8px 8px;
}
.curtain {
margin: auto auto 20px;
max-width: 640px;
border: 21px solid;
border-radius: 12px;
border-color: #000 #101010 #000 #101010;
position: relative;
}
@media screen and (max-width: 500px) {
.curtain {
margin-bottom: 10px;
}
}
.curtain::before {
content: "";
position: absolute;
top: -2px;
left: -2px;
right: -2px;
bottom: -2px;
background: #0a0a0a;
border: 1px solid;
border-color: #000 #101010 #000 #101010;
}
.curtain::after {
content: "";
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 0;
outline: 1px solid #333;
pointer-events: none;
}
.curtain.slide::after {
outline: 1px solid #0059dd;
transition: outline 2s ease-in;
}
.ratio-keeper {
position: relative;
height: 0;
padding-top: 56.25%;
margin: auto;
overflow: hidden;
}
.video-two {
position: absolute;
height: 100%;
width: 100%;
top: 0;
transition: all 8s ease-in 0s;
transition-delay: 300ms;
background: url("https://i.imgur.com/r7jVjFW.png");
background-position: 0 0;
background-size: cover;
background-repeat: no-repeat;
z-index: 1;
}
.curtain.slide .video-two {
transform: translateY(-100%);
}
.video-three {
position: absolute;
height: 100%;
width: 100%;
top: 0;
transition: all 8s ease-in 0s;
transition-delay: 300ms;
background: linear-gradient(
45deg,
#0000 7px,
rgb(113, 121, 126) 0 7.5px,
#0000 0 10px
),
linear-gradient(-45deg, #0000 7px, rgb(113, 121, 126) 0 7.5px, #0000 0 10px),
url(https://i.imgur.com/caaqjmV.jpg);
background-position: 0 0, 0 0, 0 0;
background-size: 10px 10px, 10px 10px, cover;
background-repeat: repeat, repeat, no-repeat;
filter: drop-shadow(0 0 5px #000);
z-index: 1;
}
.curtain.slide .video-three {
transform: translateY(-100%);
}
.video-four {
position: absolute;
height: 100%;
width: 100%;
top: 0;
transition: all 8s ease-in 0s;
transition-delay: 300ms;
background: linear-gradient(
45deg,
#0000 7px,
rgb(113, 121, 126) 0 7.5px,
#0000 0 10px
),
linear-gradient(-45deg, #0000 7px, rgb(113, 121, 126) 0 7.5px, #0000 0 10px),
url(https://i.imgur.com/caaqjmV.jpg);
background-position: 0 0, 0 0, 0 0;
background-size: 10px 10px, 10px 10px, cover;
background-repeat: repeat, repeat, no-repeat;
filter: drop-shadow(0 0 5px #000);
z-index: 1;
}
.curtain.slide .video-four {
transform: translateY(-100%);
}
.video-five {
position: absolute;
height: 100%;
width: 100%;
top: 0;
transition: all 8s ease-in 0s;
transition-delay: 300ms;
background: linear-gradient(
45deg,
#0000 7px,
rgb(113, 121, 126) 0 7.5px,
#0000 0 10px
),
linear-gradient(-45deg, #0000 7px, rgb(113, 121, 126) 0 7.5px, #0000 0 10px),
url(https://i.imgur.com/caaqjmV.jpg);
background-position: 0 0, 0 0, 0 0;
background-size: 10px 10px, 10px 10px, cover;
background-repeat: repeat, repeat, no-repeat;
filter: drop-shadow(0 0 5px #000);
z-index: 1;
}
.curtain.slide .video-five {
transform: translateY(-100%);
}
.video-six {
position: absolute;
height: 100%;
width: 100%;
top: 0;
transition: all 8s ease-in 0s;
transition-delay: 300ms;
background: linear-gradient(
45deg,
#0000 7px,
rgb(113, 121, 126) 0 7.5px,
#0000 0 10px
),
linear-gradient(-45deg, #0000 7px, rgb(113, 121, 126) 0 7.5px, #0000 0 10px),
url(https://i.imgur.com/caaqjmV.jpg);
background-position: 0 0, 0 0, 0 0;
background-size: 10px 10px, 10px 10px, cover;
background-repeat: repeat, repeat, no-repeat;
filter: drop-shadow(0 0 5px #000);
z-index: 1;
}
.curtain.slide .video-six {
transform: translateY(-100%);
}
/*.embed-youtube img,*/
.embed-youtube iframe,
.embed-youtube .embed-youtube-play,
.embed-youtube .embed-youtube-play:before {
position: absolute;
}
.embed-youtube iframe {
height: 100%;
width: 100%;
top: 0;
left: 0;
/*animation: fadein 3s ease-in 0s forwards;*/
}
.embed-youtube iframe {
}
@keyframes fade {
0% {
opacity: 0;
visibility: hidden;
}
100% {
opacity: 1;
visibility: visible;
}
}
.embed-youtube .embed-youtube-play {
-webkit-appearance: none;
appearance: none;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
margin: auto;
display: flex;
justify-content: center;
align-items: center;
width: 90px;
height: 90px;
border-radius: 50%;
cursor: pointer;
border: 9px solid blue;
background: transparent;
filter: drop-shadow(3px 3px 3px #000000b3);
z-index: 1;
}
.embed-youtube-play::before {
content: "";
width: 0;
height: 0;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
border-left: 27px solid blue;
transform: translateX(4px);
}
.embed-youtube-play:hover {
box-shadow: 0 0 0 5px rgba(43, 179, 20, 0.5);
}
.embed-youtube-play:focus {
outline: 0;
box-shadow: 0 0 0 5px rgba(0, 255, 255, 0.5);
}
.exit {
position: absolute;
top: auto;
bottom: -47.63px;
margin: auto;
right: 0;
left: 0;
width: 47px;
height: 47px;
cursor: pointer;
border-radius: 100%;
background: transparent;
border: 5px solid red;
box-sizing: border-box;
opacity: 1;
clip-path: circle(50%);
}
.exit::before,
.exit::after {
content: "";
background-color: red;
width: 47px;
height: 5px;
position: absolute;
top: 0px;
left: -5px;
right: 0;
bottom: 0;
margin: auto;
}
.exit::before {
transform: rotate(45deg);
}
.exit::after {
transform: rotate(-45deg);
}
.container2 .container {
background: #302b63;
}
.container2:not(.hide) .container {
animation: newbg 5s ease forwards;
}
@keyframes newbg {
to {
background: teal;
}
}
.bg1 {
animation: fadeInBody 5s ease 3s forwards;
}
@keyframes fadeInBody {
to {
background: teal;
}
}
.hide {
display: none;
}
.bg1 .container1.hide {
display: flex;
animation: hideContainer 3s ease forwards;
}
@keyframes hideContainer {
0% {
opacity: 1];
}
99% {
visibility: visible;
}
100% {
visibility: hidden;
opacity: 0;
}
}
.container2:not(.hide) {
display: block;
animation: container2 4s ease 2s forwards;
opacity: 0;
}
@keyframes container2 {
to {
opacity: 1;
}
}
const manageCover = (function makeManageCover() {
// const config = {};
function show(el) {
el.classList.remove("hide");
}
function hide(el) {
el.classList.add("hide");
}
function showCover(playButton) {
const cover = playButton.parentElement;
cover.classList.add("active");
}
function openCurtain(curtain) {
curtain.classList.add("slide");
}
function coverClickHandler(evt) {
const cover = evt.currentTarget;
showCover(cover);
const curtain = evt.currentTarget.parentElement.parentElement.parentElement;
openCurtain(curtain);
}
const covers = document.querySelectorAll(".embed-youtube-play");
covers.forEach(function addHandler(cover) {
cover.addEventListener("click", coverClickHandler);
});
function addClickToButtons(playButtons) {
function playButtonHandler(playButton) {
playButton.addEventListener("click", coverClickHandler);
}
}
function addCoverHandler(coverSelector, handler) {
const cover = document.querySelector(coverSelector);
cover.addEventListener("click", handler);
}
function init(/*selectors*/) {
//config.containers = document.querySelector(selectors.container);
//const allContainers = document.querySelector(".container");
//const playButtons = document.querySelector(selectors.playButton);
//const allPlaybuttons = document.querySelector(".embed-youtube-play");
addClickToButtons(/*allPlaybuttons*/);
}
return {
addCoverHandler,
init
};
})();
const manageUI = (function makeManageUI() {
//const config = {};
function show(el) {
el.classList.remove("hide");
document.querySelector("body").classList.add("bg1");
}
function hide(el) {
el.classList.add("hide");
}
function exitClickHandler() {
const thewrap = document.querySelector(".container2");
show(thewrap);
const cover = document.querySelector(".container1");
hide(cover);
}
function addClickToExit(exitButtons) {
exitButtons.forEach(function addExitButtonHandler(exitButtons) {
exitButtons.addEventListener("click", exitClickHandler);
});
}
function addExitHandlers(callback) {
const resetVideo = document.querySelectorAll(".exit");
resetVideo.forEach(function resetVideoHandler(video) {
video.addEventListener("click", callback);
});
}
function init() {
const exitButtons = document.querySelectorAll(".exit");
addClickToExit(exitButtons);
}
return {
addExitHandlers,
init
};
})();
const videoPlayer = (function makeVideoPlayer() {
let player;
const tag = document.createElement("script");
tag.src = "https://www.youtube.com/player_api";
const firstScriptTag = document.getElementsByTagName("script")[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
function shufflePlaylist(player) {
player.setShuffle(true);
player.playVideoAt(0);
//player.stopVideo();
}
function onPlayerReady(event) {
player = event.target;
player.setVolume(100);
//shufflePlaylist(player);
}
function onPlayerStateChange(event) {
const player = event.target;
return player;
}
function addPlayer(video, playerOptions) {
playerOptions.videoId = playerOptions.videoId || video.dataset.id;
playerOptions.events = playerOptions.events || {};
playerOptions.events.onReady = onPlayerReady;
playerOptions.events.onStateChange = onPlayerStateChange;
//playerOptions.playerVars.loop = 1;
const player = new YT.Player(video, playerOptions);
return player;
}
return {
addPlayer
};
})();
const managePlayer = (function makeManagePlayer() {
const playerVars = {
autoplay: 1,
controls: 1,
disablekb: 1,
// enablejsapi: 1,
//loop: 1,
//playlist: 1,
fs: 0,
iv_load_policy: 3
};
const defaults = {
height: 360,
host: "https://www.youtube-nocookie.com",
playerVars,
width: 640
};
function show(el) {
el.classList.remove("hide");
}
function combinePlayerOptions(opts1 = {}, opts2 = {}) {
const combined = Object.assign({}, opts1, opts2);
Object.keys(opts1).forEach(function checkObjects(prop) {
if (typeof opts1[prop] === "object") {
combined[prop] = Object.assign({}, opts1[prop], opts2[prop]);
}
});
return combined;
}
function createPlayer(videoWrapper, playerOptions = {}) {
const video = videoWrapper.querySelector(".video");
const options = combinePlayerOptions(defaults, playerOptions);
return videoPlayer.addPlayer(video, options);
}
function playerAdder(parent, playerOptions) {
const wrapper = parent;
// const wrapper = parent.document.querySelector(".wrap");
return function callback() {
initPlayer(wrapper, playerOptions);
};
}
function removePlayer(wrapper) {
wrapper.player.destroy();
delete wrapper.player;
console.log("removePlayer");
}
function removePlayerHandler(evt) {
const el = evt.target;
//const container = el.closest(".container");
const wrapper = document.querySelector(".wrap");
if (wrapper.player) {
return removePlayer(wrapper);
}
}
function initPlayer(wrapper, playerOptions) {
show(wrapper);
const player = createPlayer(wrapper, playerOptions);
wrapper.player = player;
}
return {
adder: playerAdder,
removePlayerHandler
};
})();
const players = (function coverUIPlayerFacade() {
function addPlayer(coverSelector, playerOptions) {
const parent = document.querySelector(coverSelector).parentElement;
const callback = managePlayer.adder(parent, playerOptions);
manageCover.addCoverHandler(coverSelector, callback);
}
function init() {
manageCover.init({
container: ".container",
playButton: ".embed-youtube-play"
});
manageUI.init({});
manageUI.addExitHandlers(managePlayer.removePlayerHandler);
}
return {
add: addPlayer,
init
};
})();
players.init();
function onYouTubeIframeAPIReady() {
players.add(".playa", {
playerVars: {
loop: 1,
playlist: "djV11Xbc914"
}
});
players.add(".playb", {});
players.add(".playc", {});
players.add(".playd", {});
players.add(".playe", {
playerVars: {
playlist: ["mnfmQe8Mv1g", "M7lc1UVf-VE", "-Xgi_way56U", "CHahce95B1g"]
}
});
players.add(".playf", {});
}
Also see: Tab Triggers