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.
<body>
<div class="wrapper">
<div class="wrap">
<header>
<div class="logo"></div>
<nav>
<ul>
<li></li>
<li></li>
<li></li>
</ul>
</nav>
</header>
<div class="arrow animated bounce"></div>
<section class="transparent">
<div class="headline"></div>
<div class="text"></div>
<div class="text"></div>
<div class="button"></div>
</section>
<section class="cards">
<div class="card">
<img src="https://imgplaceholder.com/500x300/transparent/ddd/ion-image" alt="">
<div class="content">
<div class="headline"></div>
<div class="text"></div>
<div class="text"></div>
<div class="button"></div>
</div>
</div>
<div class="card">
<img src="https://imgplaceholder.com/500x300/transparent/ddd/ion-image" alt="">
<div class="content">
<div class="headline"></div>
<div class="text"></div>
<div class="text"></div>
<div class="button"></div>
</div>
</div>
<div class="card">
<img src="https://imgplaceholder.com/500x300/transparent/ddd/ion-image" alt="">
<div class="content">
<div class="headline"></div>
<div class="text"></div>
<div class="text"></div>
<div class="button"></div>
</div>
</div>
</section>
<section class="contentbox">
<div class="headline"></div>
<div class="text"></div>
<div class="text"></div>
<div class="text"></div>
<div class="text"></div>
<div class="text"></div>
<div class="text"></div>
<div class="text"></div>
<div class="text"></div>
<div class="text"></div>
<div class="button"></div>
</section>
</div>
</div>
<footer>
<div class="content">
<div class="logo"></div>
<nav>
<ul>
<li></li>
<li></li>
<li></li>
</ul>
</nav>
</div>
</footer>
</body>
\:root
--clr1: #ddd
--clr2: #efefef
--clr3: #333
--clr4: tomato
--border-radius: 0px
--text-radius: 0em
body
*, :after, :before
box-sizing: border-box
background: var(--clr1)
padding: 50px 0 0 0
margin: 0 10px
.transparent
background: transparent !important
.wrap
max-width: 960px
min-width: 360px
margin: 0 auto
position: relative
&.sticky
margin-top: 150px
/* set height from header
.fluid .wrap
max-width: 100% !important
header
background: var(--clr2)
padding: 50px
width: 100%
border-radius: var(--border-radius)
position: relative
z-index: 99
.wrap.sticky header
background: var(--clr2)
padding: 50px
position: fixed
top: 0px
max-width: 960px
width: calc(100% - 20px)
min-width: 360px
border-radius: 0px 0px var(--border-radius) var(--border-radius)
.fluid .wrap.sticky header
max-width: 100% !important
header
.logo
background: var(--clr4)
width: 50px
height: 50px
border-radius: var(--text-radius)
nav
position: absolute
right: 0
top: 50%
transform: translate(-50px, -50%)
ul li
display: inline-block
list-style: none
width: 60px
height: 10px
background: var(--clr3)
border-radius: var(--text-radius)
section
background: var(--clr2)
padding: 100px 50px
width: 100%
border-radius: var(--border-radius)
position: relative
margin: 10px 0 0 0
.headline
display: block
margin: 0 auto
list-style: none
max-width: 260px
height: 30px
background: var(--clr3)
border-radius: var(--text-radius)
.text
display: block
margin: 10px auto
max-width: 500px
height: 14px
background: var(--clr3)
border-radius: var(--text-radius)
.button
display: block
margin: 20px auto 0 auto
max-width: 120px
height: 35px
background: var(--clr4)
border-radius: var(--text-radius)
&.contentbox
.headline
margin: 10px 0 !important
max-width: 65%
.text
margin: 10px 0 !important
max-width: 100%
.button
margin: 10px 0 !important
&.cards
padding: 0px
background: transparent
display: table
.card
background: var(--clr2)
width: calc(33.6% - 10px)
margin: 0 5px
border-radius: var(--border-radius)
display: inline-block
&:first-child
margin: 0 5px 0 0
&:last-child
margin: 0 0 0 5px
.content
padding: 40px
img
width: 100%
height: auto
border-radius: var(--border-radius) var(--border-radius) 0px 0px
footer
background: var(--clr3)
padding: 50px
width: 100%
border-radius: 0
position: relative
.logo
background: var(--clr2)
width: 50px
height: 50px
border-radius: var(--text-radius)
nav
position: absolute
right: 0
top: 50%
transform: translate(-50px, -50%)
ul li
display: inline-block
list-style: none
width: 60px
height: 10px
background: var(--clr2)
border-radius: var(--text-radius)
@media (max-width: 728px)
section.cards .card
width: 100%
display: block
margin: 10px 0 0 0 !important
padding: 0
body
margin: 0px
padding: 0px
.wrap
z-index: 1
position: relative
height: 100%
padding: 50px 0 0 0
background: var(--clr1)
.wrapper
box-shadow: 0px 0px 40px rgba(0, 0, 0, 0.8)
z-index: 1
footer
position: relative
z-index: -2
height: 270px
background: var(--clr4)
.content
position: fixed
z-index: 1
left: 50%
bottom: 110px
transform: translate(-50%, 0)
width: 100%
max-width: 960px
padding: 0 50px
section
&:last-child
margin-bottom: 100px
@keyframes bounce
0%, 20%, 50%, 80%, 100%
-moz-transform: translateY(0)
-ms-transform: translateY(0)
-webkit-transform: translateY(0)
transform: translateY(0)
40%
-moz-transform: translateY(-30px)
-ms-transform: translateY(-30px)
-webkit-transform: translateY(-30px)
transform: translateY(-30px)
60%
-moz-transform: translateY(-15px)
-ms-transform: translateY(-15px)
-webkit-transform: translateY(-15px)
transform: translateY(-15px)
.arrow
position: fixed
bottom: 50px
left: 50%
cursor: pointer
margin-left: -20px
width: 20px
height: 20px
padding: 20px
z-index: 99
background-color: var(--clr4)
border-radius: 50em
background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAxNi4wLjAsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+DQo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkxheWVyXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IiB3aWR0aD0iNTEycHgiIGhlaWdodD0iNTEycHgiIHZpZXdCb3g9IjAgMCA1MTIgNTEyIiBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDAgMCA1MTIgNTEyIiB4bWw6c3BhY2U9InByZXNlcnZlIj4NCjxwYXRoIGZpbGw9IiNGRkZGRkYiIGQ9Ik0yOTMuNzUxLDQ1NS44NjhjLTIwLjE4MSwyMC4xNzktNTMuMTY1LDE5LjkxMy03My42NzMtMC41OTVsMCwwYy0yMC41MDgtMjAuNTA4LTIwLjc3My01My40OTMtMC41OTQtNzMuNjcyICBsMTg5Ljk5OS0xOTBjMjAuMTc4LTIwLjE3OCw1My4xNjQtMTkuOTEzLDczLjY3MiwwLjU5NWwwLDBjMjAuNTA4LDIwLjUwOSwyMC43NzIsNTMuNDkyLDAuNTk1LDczLjY3MUwyOTMuNzUxLDQ1NS44Njh6Ii8+DQo8cGF0aCBmaWxsPSIjRkZGRkZGIiBkPSJNMjIwLjI0OSw0NTUuODY4YzIwLjE4LDIwLjE3OSw1My4xNjQsMTkuOTEzLDczLjY3Mi0wLjU5NWwwLDBjMjAuNTA5LTIwLjUwOCwyMC43NzQtNTMuNDkzLDAuNTk2LTczLjY3MiAgbC0xOTAtMTkwYy0yMC4xNzgtMjAuMTc4LTUzLjE2NC0xOS45MTMtNzMuNjcxLDAuNTk1bDAsMGMtMjAuNTA4LDIwLjUwOS0yMC43NzIsNTMuNDkyLTAuNTk1LDczLjY3MUwyMjAuMjQ5LDQ1NS44Njh6Ii8+DQo8L3N2Zz4=)
background-size: 20px 15px
background-repeat: no-repeat
background-position: center
.bounce
-moz-animation: bounce 2s infinite
-webkit-animation: bounce 2s infinite
animation: bounce 2s infinite
$(window).on('scroll', function() {
if ($(window).scrollTop() + $(window).height() > $('.wrapper').outerHeight()) {
$('.arrow').hide();
} else {
$('.arrow').show();
}
});
$('.arrow').click(function(){
$("html").animate({ scrollTop: $('html').prop("scrollHeight")}, 1200);
});
Also see: Tab Triggers