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.
<main class="view0--active">
<div class="modal">
<div class="nav default-color">
<div class="next nav-icon"><svg fill="#ececec" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M8.59 16.34l4.58-4.59-4.58-4.59L10 5.75l6 6-6 6z"/><path d="M0-.25h24v24H0z" fill="none"/></svg></div>
<div class="prev nav-icon"><svg fill="#ececec" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M15.41 16.09l-4.58-4.59 4.58-4.59L14 5.5l-6 6 6 6z"/><path d="M0-.5h24v24H0z" fill="none"/></svg></div>
</div>
<div class="modal__body">
<div class="circ">
<div class="circ3 default-color"></div>
<div class="circ2"></div>
<div class="circ1 default-color"></div>
</div>
<div class="content">
<div class="tt">
<h1 class="content__title"></h1>
<p class="content__desc"></p>
</div>
</div>
</div>
</div>
</main>
*, *:before, *:after
padding 0
margin 0
box-sizing border-box
box(arg)
width arg
height arg
// colors
color1 = #ff885d
color2 = #ACD8AA
color3 = #94B9AF
color4 = #06D6A0
.view0--active
background color1
.default-color
background color1
.view1--active
background color2
.default-color
background color2
.view2--active
background color3
.default-color
background color3
.view3--active
background color4
.default-color
background color4
body
height 100vh
width 100vw
overflow hidden
main
box(100%)
display flex
align-items center
justify-content center
transition .5s
.modal
height 400px
width 700px
border-radius 5px
position relative
&__body
box(100%)
box-shadow 0 0 38px 0 rgba(#000, .53)
position relative
overflow hidden
.nav
left 40px
bottom -40px
width 80px
height 40px
position absolute
box-shadow 0 0 38px 0 rgba(#000, .53)
transform translateY(-30px)
opacity 0
animation nav-animation .5s 1s ease forwards
transition .5s
.nav-icon
box(40px)
position absolute
top 0
display flex
align-items center
justify-content center
cursor pointer
transition .3s
.prev
left 0
&:hover
transform translateX(-2px)
.next
right 0
&:hover
transform translateX(2px)
.content
position absolute
top 0
left 0
width 100%
height 100%
overflow hidden
overflow-y auto
padding 30px 140px 40px 50px
color #ececec
background #333
h1
padding-top 20px
font-family 'Caesar Dressing'
transform translateY(-20px)
opacity 0
animation animate-text-down 1s .6s forwards
transition .5s
p
font-family 'Open Sans Condensed'
font-size 18px
padding-top 30px
transform translateY(-20px)
opacity 0
animation animate-text-down 1s .9s forwards
transition .5s
.circ
box(300px)
position absolute
display flex
align-items center
justify-content center
bottom -150px
right -150px
z-index 10
animation main-circ 6s ease forwards infinite
transition .5s
> div
position absolute
border-radius 50%
transform scale(0)
transition .5s
.circ1
box(100px)
animation scale-circ ease .6s forwards
.circ2
box(200px)
background-color #fff
animation scale-circ ease .6s .2s forwards
.circ3
box(300px)
animation scale-circ ease .6s .4s forwards
.tt
transition .4s
body
.fade-out
.tt
opacity 0
transform translateY(-20px)
.circ
opacity 0
transform scale(.5)
// Keyframes
@keyframes animate-text-down
to
opacity 1
transform translateY(0)
@keyframes scale-circ
80%
transform scale(1.2)
100%
transform scale(1)
@keyframes nav-animation
to
transform none
opacity 1
// Inspired by: https://dribbble.com/shots/3545421-017-Email-receipt
function $(e) { return document.querySelector(e); }
var next = $('.next');
var prev = $('.prev');
var index = 0;
var randomText = [
{
title: "Yeah Mr. White! Yeah Science!",
desc: "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cum atque placeat, blanditiis soluta possimus voluptatem ea nostrum illo, in facere perspiciatis eveniet voluptatum ex quia vel eaque optio, veritatis odio!"
},
{
title: "Yeah Mr. White! Yeah Science!",
desc: "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Facilis, quos, vero earum cumque debitis nesciunt doloribus saepe, eaque, dolore ea aut. Soluta voluptatem magnam possimus suscipit culpa at impedit tempora, perferendis ducimus reprehenderit eos? Expedita ipsa, natus. Sapiente laboriosam vero, minus possimus esse odio fuga dolore minima eius, tenetur tempora!"
},
{
title: "Yeah Mr. White! Yeah Science!",
desc: "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Beatae fugit inventore."
},
{
title: "Yeah Mr. White! Yeah Science!",
desc: "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Beatae fugit inventore. <br>1. Lorem Ipsum <br>2. Lorem Ipsum <br>3. Lorem Ipsum <br>4. Lorem Ipsum"
}
];
$('.content__title').innerHTML = randomText[0].title;
$('.content__desc').innerHTML = randomText[0].desc;
next.addEventListener('click', function() {
if (index >= 0 && index <= 2) {
toggleView();
setTimeout(function() {
$('.content__title').innerHTML = randomText[index].title;
$('.content__desc').innerHTML = randomText[index].desc;
}, 500)
$('main').classList.remove('view'+index+'--active');
$('main').classList.add('view'+(index + 1)+'--active');
index++;
}
}, false);
prev.addEventListener('click', function() {
if (index > 0 && index <= 3) {
toggleView();
setTimeout(function() {
$('.content__title').innerHTML = randomText[index].title;
$('.content__desc').innerHTML = randomText[index].desc;
}, 500)
$('main').classList.remove('view'+(index)+'--active');
$('main').classList.add('view'+(index - 1)+'--active');
index--;
}
}, false)
function toggleView() {
$('main').classList.add('fade-out');
setTimeout(function() {
$('main').classList.remove('fade-out');
}, 500)
}
Also see: Tab Triggers