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="wrapper">
<svg class="header" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="none">
<polygon fill="white" points="0,0 100,100 0,100"/>
</svg>
<div class="card-container">
<div class="card-body">
<div class="side side-back">
<div class="container-fluid">
<div class="row">
<div class="product-image col-5">
<img src="https://i.imgur.com/c1DrURu.png" alt="Shoes" />
</div>
<div class="features col-7">
<h2>Features</h2>
<ul>
<li>
M Select™ DRY seals out water and lets moisture escape so you stay dry when you're on the move
</li>
<li>
Performance suede leather and mesh upper
</li>
<li>
Bellows, closed-cell foam tongue keeps moisture and debris out
</li>
<li>
Protective rubber toe cap
</li>
<li>
Breathable mesh lining
</li>
<li>
Molded nylon arch shank
</li>
<li>
Merrell air cushion in the heel absorbs shock and adds stability
</li>
<li>
Weight: 2lbs 1oz / 940G
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="side side-front">
<div class="container-fluid">
<div class="row">
<div class="product-image col-12 col-lg-5">
<img src="https://i.imgur.com/c1DrURu.png" alt="Shoes" />
</div>
<div class="content col-12 col-lg-7">
<h2>Waterproof Hiking Shoe</h2>
<div class="price-rating">
<div class="price">
<h3>Price:</h3>
<p>$99.99</p>
</div>
<div class="rating">
<h3>Rating: <span class="rating-text">4.5</span></h3>
<div id="rateYo"></div>
</div>
</div>
<div class="details">
<p>
Experience out-of-the-box comfort in this waterproof hiker. With durable leathers, a supportive footbed, and Vibram® traction, all in a versatile package, you won't doubt why Moab stands for Mother-Of-All-Boots™.
</p>
</div>
<div class="button">Add to Cart</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="flip">
<div class="flip-button">
<i class="flip-icon fa fa-angle-double-up" aria-hidden="true"></i>
</div>
<p>Flip</p>
</div>
</div>
@import url('https://fonts.googleapis.com/css?family=Anton|News+Cycle:700|Roboto');
$yellow: #FDB933;
$card-bg-color: #FFFEE1;
$brown: #915F35;
$orange: #E57740;
$gray: #8D8D8D;
$flipTime: .7s;
html {
font-size: 15px;
}
h3,
p,
ul {
margin: 0;
padding: 0;
}
body {
margin: 0;
}
.wrapper {
height: 900px;
background: $yellow;
position: relative;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
svg.header {
position: absolute;
bottom: 0;
width: 100%;
height: 50vw;
z-index: 1;
}
/* Card Container & Body */
.card-container {
width: 700px;
height: 450px;
border-radius: 5px;
box-shadow: 0 0 50px rgba(0,0,0,.2);
padding: 10px;
perspective: 1000px;
position: relative;
transform-style: preserve-3d;
transition: all $flipTime linear;
z-index: 1;
margin-top: 10px;
margin-bottom: 70px;
.card-body {
width: 100%;
height: 100%;
}
}
/*- Card sides -*/
.side {
width: 98%;
height: 97.5%;
backface-visibility: hidden;
background: #FFFEE1;
border-radius: 10px;
box-shadow: 0 0 50px rgba(0, 0, 0, 0.2);
padding: 25px;
position: absolute;
top: 1.2%;
left: 1%;
h2 {
color: $brown;
font-family: 'Anton', sans-serif;
text-transform: uppercase;
margin-bottom: 30px;
}
p,
li {
color: $gray;
font-size: 1rem;
font-family: 'Roboto', sans-serif;
}
.container-fluid {
height: 100%;
.row {
height: 100%;
}
}
}
/* Card-Sides */
.side-back {
z-index: 4;
transform: rotateX(180deg);
.product-image {
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;
img {
height: auto;
width: 20%;
margin-left: 10%;
}
}
}
.side-front {
z-index: 2;
.product-image {
position: relative;
img {
position: absolute;
left: -70%;
top: 10%;
}
}
.content {
display: flex;
flex-direction: column;
height: 100%;
}
.price-rating {
display: flex;
justify-content: space-between;
h3 {
color: $brown;
font-size: 1.2rem;
font-family: 'News Cycle', sans-serif;
text-transform: uppercase;
span {
color: $orange;
}
}
.price,
.rating {
display: flex;
flex-direction: column;
justify-content: space-between;
}
.price p {
font-size: 2rem;
font-family: 'News Cycle', sans-serif;
line-height: 2rem;
color: $orange;
}
.rating .fa {
font-size: 1.5rem;
margin-right: 0;
color: $orange;
}
}
.details {
margin: 20px 0;
padding-bottom: 10px;
border-bottom: 1px solid lighten($orange, 30%);
}
.button {
margin-top: auto;
border: 1px solid $orange;
border-radius: 40px;
color: $orange;
cursor: pointer;
display:block;
padding: 15px;
font-family: 'Roboto', sans-serif;
text-align: center;
text-transform: uppercase;
position: relative;
transition: all .3s linear;
overflow: hidden;
z-index: 3;
&:before {
position: absolute;
top: 0%;
left: -160%;
width: 150%;
height: 100%;
background: $orange;
content: ' ';
transition: all .4s ease-in;
transform: skewX(60deg);
z-index: -1;
}
&:hover {
color: #fff;
}
&:hover:before {
left: -30%;
}
}
}
/* Flip Button */
.flip {
color: $orange;
z-index:2;
display:flex;
flex-direction: column;
align-items: center;
.flip-button {
height: 60px;
width: 60px;
border: 1px solid $orange;
border-radius: 50%;
text-align: center;
padding-top: 12px;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
transition: all $flipTime ease;
.fa {
font-size: 2rem;
line-height: 1rem;
margin-bottom: 10px;
}
&:hover {
background: $orange;
color: #fff;
}
}
p {
margin-top: 10px;
font-family: 'Roboto', sans-serif;
font-size: 1rem;
text-transform: uppercase;
}
}
/* Flipping */
.flipped {
transform: rotateX(180deg);
}
.disappear {
opacity: 0;
visibility: hidden;
transition: opacity 1s ease-in, visibility .75s linear;
}
/* Rating Overrides */
.jq-ry-container {
padding: 0;
}
@media (max-width: 992px) {
.card-container {
width: 400px;
height: 600px;
}
.side-front .product-image img {
position: static;
height: 200px;
}
.side-front .product-image {
display: flex;
justify-content: center;
}
.side-front .content {
display: flex;
flex-direction: column;
height: auto;
}
}
// Inspired by this cool shot of Razvan Hosu:
// https://dribbble.com/shots/3366262-Product-presentation
function toggleFlip() {
this.classList.toggle('flipped');
var cardContainer = document.querySelector('.card-container');
cardContainer.classList.toggle('flipped');
var sideFront = document.querySelector('.side-front');
sideFront.classList.toggle('disappear');
}
var flipButton = document.querySelector('.flip-button');
flipButton.addEventListener('click', toggleFlip);
// Rating jQuery Plugin
$(function () {
$("#rateYo").rateYo({
rating: 4.5,
starWidth: "25px",
normalFill: "#f7f3cd"
}).on("rateyo.change", function (e, data) {
var rating = data.rating;
$('.rating-text').text(rating);
});
});
Also see: Tab Triggers