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 URL's 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 it's URL and the proper URL extention.
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 Skypack, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ES6 import
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="generic"></div>
<div class="mbg bg bgimg"></div>
<div class="ibg bg bgimg"></div>
<div class="gbg bg bgimg"></div>
<div class="backgrounds" onclick="noSpin()"></div>
<div class="card-wrap center">
<div onclick="spin(this)" class="card card-1">
<div class="inner">
<div class="front">
<h1>THE MARTIAN</h1>
<img src="https://connorlaw.co.uk/images/Martian-front.png" alt="Martian">
</div>
<div class="back">
<div class="back-info center">
<H2 class="m">THE MARTIAN</H2>
<p class="blurb">When astronauts blast off from the planet Mars, they leave behind Mark Watney (Matt Damon), presumed dead after a fierce storm. With only a meager amount of supplies, the stranded visitor must utilize his wits and spirit to find a way to survive on the hostile planet.<br><br>Meanwhile, back on Earth, members of NASA and a team of international scientists work tirelessly to bring him home, while his crew mates hatch their own plan for a daring rescue mission.</p>
</div>
<div class="back-buttons">
<h4>Play Now</h4>
<h4>Download</h4>
<h4>Add To List</h4>
</div>
<img src="https://connorlaw.co.uk/images/Martian-Back.png" alt="Martian">
</div>
</div>
</div><div onclick="spin(this)" class="card card-2">
<div class="inner">
<div class="front">
<h1>INTERSTELLAR</h1>
<img src="https://connorlaw.co.uk/images/Interstellar-front.png" alt="Interstellar">
</div>
<div class="back">
<div class="back-info center">
<H2 class="i">INTERSTELLAR</H2>
<p class="blurb ">In Earth's future, a global crop blight and second Dust Bowl are slowly rendering the planet uninhabitable. Professor Brand (Michael Caine), a brilliant NASA physicist, is working on plans to save mankind by transporting Earth's population to a new home via a wormhole.<br><br>But first, Brand must send former NASA pilot Cooper (Matthew McConaughey) and a team of researchers through the wormhole and across the galaxy to find out which of three planets could be mankind's new home.</p></div>
<div class="back-buttons">
<h4>Play Now</h4>
<h4>Download</h4>
<h4>Add To List</h4>
</div>
<img src="https://connorlaw.co.uk/images/Interstellar-Back.png" alt="Martian">
</div>
</div>
</div><div onclick="spin(this)" class="card">
<div class="inner">
<div class="front">
<h1>GRAVITY</h1>
<img src="https://connorlaw.co.uk/images/Gravity-front.png" alt="Gravity">
</div>
<div class="back">
<div class="back-info center">
<H2 class="g">GRAVITY</H2>
<p class="blurb ">Dr. Ryan Stone (Sandra Bullock) is a medical engineer on her first shuttle mission. Her commander is veteran astronaut Matt Kowalsky (George Clooney), helming his last flight before retirement.<br><br>Then, during a routine space walk by the pair, disaster strikes: The shuttle is destroyed, leaving Ryan and Matt stranded in deep space with no link to Earth and no hope of rescue. As fear turns to panic, they realize that the only way home may be to venture further into space.</p></div>
<div class="back-buttons">
<h4>Play Now</h4>
<h4>Download</h4>
<h4>Add To List</h4>
</div>
<img src="https://connorlaw.co.uk/images/Gravity-Back.png" alt="Martian">
</div>
</div>
</div>
</div>
* {
margin: 0 auto;
}
body {
height: 100vh;
background-image: url(https://connorlaw.co.uk/images/earth.jpg);
background-repeat: no-repeat;
}
.center {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
}
.bg {
background-repeat: no-repeat;
background-position: center;
background-size: cover;
height: 100vh;
width: 100%;
overflow: hidden;
}
.bgimg {
opacity: 0;
transition: 0.6s;
}
h1 {
font-family: 'Big Shoulders Text', cursive;
position: absolute;
width: 100%;
top: 83%;
opacity: 0.4;
right: 15px;
text-align: right;
letter-spacing: 1px;
}
.blurb {
font-family: 'Lato', sans-serif;
letter-spacing: 0.15px;
width: 300px;
height: fit-content;
text-align: center;
padding: 0rem 1rem;
box-sizing: border-box;
font-weight: 300;
font-size: 14px;
bottom: 50px;
}
.back h2 {
width: 300px;
top: 30px;
letter-spacing: 4px;
text-align: center;
font-size: 30px;
margin-bottom: 50px;
}
.back-info {
height: fit-content;
}
.back-buttons {
font-family: 'Lato', sans-serif;
letter-spacing: 0.15px;
font-size: 10px;
position: absolute;
left: 45px;
bottom: -6px;
}
h4 {
margin-bottom: 23px
}
.m {
font-family: 'Work Sans', sans-serif;
}
.i {
font-family: 'Arapey', serif;
}
.g {
font-family: 'Poppins', sans-serif;
}
.backgrounds {
height: 100vh;
width: 100vw;
background-color: white;
opacity: 0;
position: absolute;
}
.mbg {
background-image: url(https://connorlaw.co.uk/images/martian-bg.png);
position: absolute;
}
.ibg {
background-image: url(https://connorlaw.co.uk/images/interstellar-bg.png);
position: absolute;
}
.gbg {
background-image: url(https://connorlaw.co.uk/images/gravity-bg.jpg);
position: absolute;
}
.card-wrap {
width: fit-content;
height: 80vh;
}
.card {
width: 300px;
height: 80vh;
perspective: 1000px;
position: relative;
display: inline-block;
margin: 0 5vh;
transition: 0.6s;
cursor: pointer;
}
.card:hover {
transform: scale(1.05);
}
.inner {
position: absolute;
width: 100%;
height: 100%;
transition: transform 1.4s;
transform-style: preserve-3d;
}
.spin .inner {
transform: rotateY(-180deg) scale(1.1);
}
.front, .back {
position: absolute;
backface-visibility: hidden;
width: 300px;
height: 600px;
color: #fff;
}
img {
width: 100%;
height: 100%;
border-radius: 20px;
}
.back {
transform: rotateY(-180deg);
}
let bgs = document.getElementsByClassName("bgimg");
function spin(card) {
noSpin();
card.classList.add("spin");
if (card.classList.contains("card-1")) {
bgs[0].style.opacity = 1;
} else if (card.classList.contains("card-2")) {
bgs[1].style.opacity = 1;
} else if (card.classList.contains("card-3")) {
bgs[2].style.opacity = 1;
};
};
function noSpin() {
let cards = document.getElementsByClassName("card");
for (let i = 0; i < cards.length; i++) {
cards[i].classList.remove("spin");
};
for (let i = 0; i < bgs.length; i++) {
bgs[i].style.opacity = 0;
};
};
Also see: Tab Triggers