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 URL's 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 it's URL and the proper URL extention.
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 Skypack, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ES6 import
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.
<header id="header">
<div class="wrap">
<h1 class="logo">Testes</h1>
<ul class="menu">
<li>
<a href="#section-01">One</a>
</li>
<li>
<a href="#section-02">Two</a>
</li>
</ul>
</div>
</header>
<div id="main">
<section class="section" id="section-01">
<div class="wrap">
<img src="http://i66.tinypic.com/j6ke9u.jpg" />
<h1>Your shields were failing, sir</h1>
<p>Did you come here for something in particular or just general Riker-bashing? When has justice ever been as simple as a rule book? They were just sucked into space. I suggest you drop it, Mr. Data. The Enterprise computer system is controlled by three primary main processor cores, cross-linked with a redundant melacortz ramistat, fourteen kiloquad interface modules. Well, that's certainly good to know. Yes, absolutely, I do indeed concur, wholeheartedly!</p>
</div>
</section>
<section class="section" id="section-02">
<div class="wrap">
<img src="http://i64.tinypic.com/de2uch.jpg" />
<h1>Commander William Riker of the Starship Enterprise</h1>
<p>I am your worst nightmare! Mr. Crusher, ready a collision course with the Borg ship. This is not about revenge. This is about justice. Yes, absolutely, I do indeed concur, wholeheartedly! Sure. You'd be surprised how far a hug goes with Geordi, or Worf. I will obey your orders. I will serve this ship as First Officer. And in an attack against the Enterprise, I will die with this crew. But I will not break my oath of loyalty to Starfleet. Yesterday I did not know how to eat gagh.</p>
</div>
</section>
</div>
* {
margin:0;
padding:0;
}
body {
font-family: 'Raleway', sans-serif;
color:#fff;
font-size:14px;
overflow-X:hidden;
}
.wrap {
max-width:90%;
margin:0 auto;
width:100%;
position: relative;
top: 50%;
transform:translateY(-50%);
}
#header {
height: 70px;
width: 100%;
position: fixed;
top: 0;
left: 0;
z-index: 6;
.wrap {
overflow:hidden;
height:auto;
}
}
.logo {
font-family: 'Baloo Bhai', cursive;
font-size:24px;
float:left;
}
.menu {
float:right;
list-style:none;
padding-top:20px;
li {
display:inline-block;
font-size:14px;
margin:0 10px;
text-transform:uppercase;
a {
color:#fff;
text-decoration:none;
}
}
}
h1 {
font-family: 'Baloo Bhai', cursive;
color:#fff;
font-size:32px;
font-weight:normal;
line-height:1;
margin: 0 0 20px;
}
.section {
height:100vh;
text-align:center;
img {
display:block;
margin:0 auto 20px;
height:auto;
width:100px;
border-radius:50%;
overflow:hidden;
border:5px solid #fff;
}
}
#section-01 {
background:rgba(22,139,255,1);
}
#section-02 {
background:rgba(255,99,22,1);
}
#footer {
font-size:12px;
position:fixed;
bottom:0;
left:0;
width:100%;
text-align:center;
.wrap {
padding:10px 0;
}
}
// Init ScrollMagic
var controller = new ScrollMagic.Controller();
var section1MTl,
section2MTl;
installMediaQueryWatcher("(max-width: 640px)", function(matches) {
if (matches) {
// Section 01
section1MTl = new TimelineMax()
.from('#section-01 img', .5, {y: '110%',autoAlpha:0, ease:Power4.easeInOut})
.from('#section-01 h1', .5, {y: '110%', autoAlpha:0,ease:Power4.easeInOut})
.from('#section-01 p', .5, {y: '110%', autoAlpha:0,ease:Power4.easeInOut})
;
section2MTl = new TimelineMax()
.from('#section-02 img', .5, {y: '110%',autoAlpha:0, ease:Power4.easeInOut})
.from('#section-02 h1', .5, {y: '110%', autoAlpha:0,ease:Power4.easeInOut})
.from('#section-02 p', .5, {y: '110%', autoAlpha:0,ease:Power4.easeInOut})
;
} else {
// Section 01
section1MTl = new TimelineMax()
.from('#section-01 img', .5, {x: '110%',autoAlpha:0, ease:Power4.easeInOut})
.from('#section-01 h1', .5, {x: '110%', autoAlpha:0,ease:Power4.easeInOut})
.from('#section-01 p', .5, {x: '110%', autoAlpha:0,ease:Power4.easeInOut})
;
section2MTl = new TimelineMax()
.from('#section-02 img', .5, {x: '110%', autoAlpha:0,ease:Power4.easeInOut})
.from('#section-02 h1', .5, {x: '-110%', autoAlpha:0,ease:Power4.easeInOut})
.from('#section-02 p', .5, {x: '110%', autoAlpha:0,ease:Power4.easeInOut})
;
}
});
new ScrollMagic.Scene({
triggerElement: '#section-01',
triggerHook: .8
})
.setTween(section1MTl)
.addTo(controller);
new ScrollMagic.Scene({
triggerElement: '#section-02',
triggerHook: .8
})
.setTween(section2MTl)
.addTo(controller);
// Media Query Watch
function installMediaQueryWatcher(mediaQuery, layoutChangedCallback) {
var mql = window.matchMedia(mediaQuery);
mql.addListener(function (e) { return layoutChangedCallback(e.matches); });
layoutChangedCallback(mql.matches);
}
Also see: Tab Triggers