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.
<nav class="section__nav">
<ul class="section__nav-list">
<li class="section__nav-item">
<a href="" class="section__nav-link"><svg x="0" y="0" width="200" height="200" viewBox="0 0 200 200" enable-background="new 0 0 200 200" xml:space="preserve"><path d="M199 99.5c0 55-44.5 99.5-99.5 99.5 -55 0-99.5-44.5-99.5-99.5C0 44.5 44.5 0 99.5 0 154.5 0 199 44.5 199 99.5z"/></svg>
</a>
</li>
<li class="section__nav-item">
<a href="" class="section__nav-link">
<svg x="0" y="0" width="200" height="200" viewBox="0 0 200 200" enable-background="new 0 0 200 200" xml:space="preserve"><polygon points="0 187 100 13.8 200 187 "/></svg>
</a>
</li>
<li class="section__nav-item">
<a href="" class="section__nav-link">
<svg x="0" y="0" width="200" height="200" viewBox="0 0 200 200" enable-background="new 0 0 200 200" xml:space="preserve"><rect width="200" height="200"/></svg>
</a>
</li>
<li class="section__nav-item">
<a href="" class="section__nav-link">
<svg x="0" y="0" width="200" height="200" viewBox="0 0 200 200" enable-background="new 0 0 200 200" xml:space="preserve"><polygon points="38 194 0 77.8 99.6 5.9 199.1 77.6 161.1 194 "/></svg>
</a>
</li>
</ul>
</nav>
<section class="section">
<div class="section__wrapper">
<h1 class="section__title">Circle</h1>
<p>A circle is a simple shape in Euclidean geometry. It is the set of all points in a plane that are at a given distance from a given point.</p>
</div>
</section>
<section class="section">
<div class="section__wrapper">
<h1 class="section__title">Triangle</h1>
<p>A triangle is a polygon with three edges and three vertices. It is one of the basic shapes in geometry.</p>
</div>
</section>
<section class="section">
<div class="section__wrapper">
<h1 class="section__title">Square</h1>
<p>In geometry, a square is a regular quadrilateral, which means that it has four equal sides and four equal angles (90-degree angles, or right angles).</p>
</div>
</section>
<section class="section">
<div class="section__wrapper">
<h1 class="section__title">Pentagon</h1>
<p>In geometry, a pentagon is any five-sided polygon. A pentagon may be simple or self-intersecting.</p>
</div>
</section>
<section class="section">
<div class="section__wrapper">
<h1 class="section__title">Space</h1>
<p>Space is the boundless three-dimensional extent in which objects and events have relative position and direction.</p>
</div>
</section>
<!-- Ettrics -->
<a href="http://ettrics.com/blog/" class="logo" target="_blank">
<img class="logo" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/45226/ettrics-logo.svg" alt="" />
</a>
align()
display flex
align-items center
justify-content center
easeout(s=.5s)
transition all s cubic-bezier(0.23, 1, 0.32, 1)
*
box-sizing: border-box
body
line-height: 1.5
overflow hidden
background #2694f1
font-family Roboto
-webkit-font-smoothing antialiased
ul
list-style-type: none
margin: 0
padding: 0
.section
will-change transform
height: 100vh
align()
easeout(.7s)
&:last-of-type
background #333
@media (max-width 720px)
align-items flex-end
&__wrapper
padding: 0 4vw
margin-left 50%
@media (max-width 720px)
margin-left 20vw
margin-bottom 50px
@media (max-width 500px)
margin-left 30vw
&__nav
position fixed
z-index 3
top 0
left 0
height 100vh
align()
@media (max-width 720px)
width 20vw
background: rgba(black, 0.2);
@media (max-width 500px)
width 25vw
&__nav-item
margin: 10px 0
.section__nav-link.active
> svg
opacity 1
stroke-width 20px
stroke rgba(white, 0.3)
&:nth-child(1)
.section__nav-link.active
> svg
transform scale(4) translate(6.2vw, 40px)
&:nth-child(2)
.section__nav-link.active
> svg
transform scale(4) translate(6.2vw, 15px)
&:nth-child(3)
.section__nav-link.active
> svg
transform scale(4) translate(6.2vw, -10px)
&:nth-child(4)
.section__nav-link.active
> svg
transform scale(4) translate(6.2vw, -30px)
@media (max-width 720px)
&:nth-child(1)
.section__nav-link.active
> svg
transform scale(3.5) translate(55px, 20px)
&:nth-child(2)
.section__nav-link.active
> svg
transform scale(3.5) translate(60px, -5px)
&:nth-child(3)
.section__nav-link.active
> svg
transform scale(4) translate(60px, -25px)
&:nth-child(4)
.section__nav-link.active
> svg
transform scale(4) translate(50px, -55px)
@media (max-width: 500px)
&:nth-child(1)
.section__nav-link.active
> svg
transform scale(3) translate(48px, 3.5vh)
&:nth-child(2)
.section__nav-link.active
> svg
transform scale(3) translate(50px, -0.7vh)
&:nth-child(3)
.section__nav-link.active
> svg
transform scale(3) translate(50px, -2.5vh)
&:nth-child(4)
.section__nav-link.active
> svg
transform scale(3) translate(48px, -8.5vh)
&__nav-link
display block
transform none
svg
will-change transform, opacity, stroke
width 70px
height 70px
margin 0 4vw
fill #00ffcf
opacity 0.5
padding 10px
easeout()
@media (max-width 500px)
width 55px
height 55px
&__title
color #00ffcf
font-weight 300
margin 0 0 25px 0
@media (max-width 720px)
margin 0 0 13.5px 0
p
font-size 20px
margin 0
color rgba(black, 0.8)
max-width 640px
@media (max-width 720px)
font-size 16px
.logo
position: fixed
bottom: 3vh
right: 3vw
z-index: 4
img
width: 45px
var Shapes = (function() {
var link = $('.section__nav-link');
var section = $('.section');
var svg = $('.section__nav-link > svg');
var toggleSection = function() {
var i = $(this).parents('li').index();
link.removeClass('active')
svg.removeAttr('style');
$(this).addClass('active');
section.css({
'transform': 'translateY(-' + i +'00%)',
'-webkit-transform': 'translateY(-' + i +'00%)'
});
return false;
};
var toggleSpace = function() {
if ($(this).parent().hasClass('active')) {
link.removeClass('active');
section.css('opacity', 0);
section.on('transitionend', function() {
section.css({
'transform': 'translateY(-400%)',
'-webkit-transform': 'translateY(-400%)',
});
section.on('transitionend', function() {
section.css('opacity', '1');
section.off('transitionend');
});
});
return false;
}
};
var showFirst = function() {
link.eq(0).addClass('active');
};
var bindActions = function() {
link.on('click', toggleSection);
svg.on('click', toggleSpace);
showFirst();
};
var init = function() {
bindActions();
};
return {
init: init
};
}());
Shapes.init();
Also see: Tab Triggers