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.wrapper
div.cap
h4.header Gem Encyclopaedia
div.body
div.carousel-container
div.carousel
div.carousel-item
div.item
div.gem.purple
div.carousel-item
div.item
div.gem.red
div.carousel-item
div.item
div.gem.blue
div.carousel-item
div.item
div.gem.green
div.content
p.instructions.
Swipe up and down with the arrow keys or mouse to view the different gems.
div.item-content
h3.header Item description
p.description.
You won’t get good at anything by doing it a lot fucking aimlessly. Intuition is fucking important. Never let your guard down by thinking you’re fucking good enough. Design as if your fucking life depended on it. Your rapidograph pens are fucking dried up, the x-acto blades in your bag are rusty, and your mind is dull.
div.footer
div.col-side
input(type="button", value="Level 3").level-btn
div.col-center
span.progress-bar
span.progress-bar__value
div.col-side
input(type="button", value="Level 4").level-btn
div.disclaimer
p Vertical carousels though.
// Compass
@import "compass";
// Font
@import url(https://fonts.googleapis.com/css?family=Roboto:300,400,500,700);
// Variables
$border-radius: 5px;
$color-purple: #48466D;
$gem-blue: #4AA0D5;
$gem-red: #E84545;
$gem-green: #B7E576;
$gem-purple: #6A2C70;
*, *:after, *:before {
box-sizing: border-box;
}
body, html {
height: 100%;
overflow: hidden;
width: 100%;
}
body {
background-color: #311d3f;
font-family: 'Roboto', Arial, sans-serif;
@include filter-gradient(#311d3f, #88304e, horizontal);
@include background-image(linear-gradient(left top, #311d3f 0%, #522546 60%, #522546 60%, #88304e 100%));
}
.disclaimer {
color: #fff;
margin: 50px auto 20px;
opacity: .7;
text-align: center;
width: 600px;
p {
font-weight: 300;
line-height: 160%;
}
a {
color: #fff;
font-weight: 500;
text-decoration: none;
transition: all .15s linear;
&:hover {
margin: 0 10px;
}
}
}
.wrapper {
margin: 40px auto;
width: 700px;
}
.cap {
background: #f5f5f5;
border-bottom: 1px solid #e5e5e5;
border-radius: $border-radius $border-radius 0 0;
padding: 20px;
text-align: center;
.header {
font-size: 18px;
}
.hamburger {
opacity: .3;
&:before {
font-size: 24px;
}
}
}
.body {
background: #fff;
color: #333;
overflow: auto;
.header {
font-size: 18px;
font-weight: 700;
margin: 20px 0 15px;
text-transform: capitalize;
}
.description {
color: #666;
font-size: 16px;
line-height: 150%;
}
.instructions {
line-height: 150%;
margin-bottom: 50px;
opacity: .5;
}
.carousel-container {
float: left;
height: 300px;
overflow: hidden;
width: 40%;
}
.content {
border-left: 1px solid #eee;
float: left;
height: 300px;
max-height: 300px;
padding: 20px;
width: 60%;
}
}
.footer {
background: #f5f5f5;
border-radius: 0 0 $border-radius $border-radius;
border-top: 1px solid #e5e5e5;
overflow: auto;
.col-side,
.col-center {
float: left;
padding: 20px;
}
.col-side {
width: 20%;
}
.col-center {
width: 60%;
}
}
// Progress bar
.progress-bar {
background: #fff;
border: 1px solid #e5e5e5;
border-radius: 15px;
display: block;
height: 30px;
margin-top: 12px;
width: 100%;
&__value {
background: #3D84A8;
background: #88304e;
border: 5px solid #fff;
border-radius: 15px;
display: block;
height: 100%;
max-width: 100%;
width: 23%;
}
}
// Level buttons
.level-btn {
background: $color-purple;
border: 3px solid $color-purple;
border-radius: 3px;
box-shadow: 0 10px 20px transparentize(#88304e, .8);
color: #fff;
cursor: pointer;
font-family: 'Roboto', Arial, sans-serif;
font-size: 16px;
outline: none;
padding: 15px;
transition: all .15s linear;
width: 100%;
&:hover {
background: darken($color-purple, 5%);
box-shadow: 0 10px 20px transparentize(#88304e, .6);
}
}
// Slick plugin
.slick-slider {
height: 50%;
margin: 30% 0 20%;
}
.slick-list {
overflow: visible;
}
.slick-slide {
opacity: .4;
outline: none;
transition: opacity .15s linear;
&.slick-active {
opacity: 1;
}
}
// Previous/Next level buttons
.item {
height: 180px;
padding: 20px;
position: relative;
text-align: center;
.item-desc {
background: #fff;
padding: 10px;
}
}
// Gems
.gem {
margin: 0 auto;
width: 80px;
height: 80px;
position: relative;
background: $gem-purple;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
transform: rotate(45deg);
@include background-image(linear-gradient(left top, $gem-purple 0%, darken($gem-purple, 15%) 100%));
&.red {
background: $gem-red;
@include background-image(linear-gradient(left top, $gem-red 0%, darken($gem-red, 15%) 100%));
}
&.blue {
background: $gem-blue;
@include background-image(linear-gradient(left top, $gem-blue 0%, darken($gem-blue, 15%) 100%));
}
&.green {
background: $gem-blue;
@include background-image(linear-gradient(left top, $gem-green 0%, darken($gem-green, 15%) 100%));
}
&:after {
border: 15px solid;
border-color: rgba(0,0,0,0.2) rgba(255,255,255,0.15) rgba(0,0,0,0.25) rgba(255,255,255,0.4);
content: "";
height: 100%;
left: 0;
position: absolute;
width: 100%;
@include background-image(linear-gradient(top, rgba(255,255,255,0.0) 0%, rgba(255,255,255,0.15) 100%));
}
}
// Gem descriptions
var gems = [{name: 'Amethyst', desc: 'The amethyst, considered the highest level crafting stone, aliquam dolores et eum. Et facilisis iracundia usu, an integre noluisse eos, ea eum quod error appetere.'},
{name: 'Ruby', desc: 'This polished ruby gem adds fire damage vel zril epicurei expetendis te, nec ea vidisse bonorum.'},
{name: 'Topaz', desc: 'Topaz, mined from the crust of the underworld, dolores et eum. Et facilisis iracundia usu, an integre noluisse eos.'},
{name: 'Emerald', desc: 'The basic emerald is not very exciting, but ea eum quod error appetere. At scribentur disputationi pro, cu quot tota singulis per.'}];
$('.content .header').html(gems[0].name);
$('.content .description').html(gems[0].desc)
var numSlides;
var $carousel = $('.carousel');
$carousel.on('beforeChange', function(event, slick, currentSlide, newSlide) {
if (newSlide !== currentSlide) {
$('.item-content').animate({ opacity: 0}, 150);
}
}).on('afterChange', function(event, slick, currentSlide) {
$('.item-content').animate({ opacity: 1}, 150);
$('.content .header').html(gems[currentSlide].name);
$('.content .description').html(gems[currentSlide].desc);
}).on('init', function(event, slick) {
numSlides = slick.slideCount;
});
$carousel.slick({
infinite: false,
vertical: true,
verticalSwiping: true,
centerPadding: '40px',
speed: 200,
focusOnSelect: true,
arrows: false
});
// Up/down arrows
$('html').keydown(function(event) {
var currentSlide = $carousel.slick('slickCurrentSlide');
// Up
if (event.keyCode === 40 && currentSlide !== 0) {
$carousel.slick("slickPrev");
}
else if (event.keyCode === 38 && numSlides - 1 !== currentSlide) {
$carousel.slick("slickNext");
}
});
Also see: Tab Triggers