JavaScript preprocessors can help make authoring JavaScript easier and more convenient. For instance, CoffeeScript can help prevent easy-to-make mistakes and offer a cleaner syntax and Babel can bring ECMAScript 6 features to browsers that only support ECMAScript 5.
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.
HTML Settings
Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.
%nav
.container
#icon.fontawesome-cog
%ul
%li
%a{href: "#"} Item 1
%li
%a{href: "#"} Item 2
%li
%a{href: "#"} Item 3
%li
%a{href: "#"} Item 4
%li
%a{href: "#"} Item 5
%header
.container
%h1 Opacity on scroll
#nav-bg
%section#about
.container
%p Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse vel diam lacus. Nam quis ipsum nec massa sagittis scelerisque ac non urna. Phasellus posuere orci ac tellus interdum mollis eu vitae mi. Aliquam nec ante lobortis, suscipit lectus eu, dignissim ante. Nam imperdiet quis eros.
@import url(https://fonts.googleapis.com/css?family=Montserrat:400,700);
@import url(http://weloveiconfonts.com/api/?family=fontawesome);
[class*="fontawesome-"]:before {
font-family: 'FontAwesome', sans-serif;
}
* {
box-sizing: border-box;
&:before, &:after {
box-sizing: border-box;
}
}
body {
background: #222;
margin: 0;
font-family: 'Montserrat', sans-serif;
font-size: 16px;
color: #FFF;
}
.container {
max-width: 60em;
min-width: 45em;
margin: 0 auto;
padding: 0 2em;
}
nav {
position: fixed;
width: 100%;
margin: 0 auto;
top: 0;
z-index: 3;
ul {
padding: 0;
margin: 0;
list-style-type: none;
float: right;
}
li {
display: inline-block;
padding: 2em;
text-align: center;
transition: all .2s;
&:last-child {
padding-right: 0;
}
}
a {
color: #FFF;
text-decoration: none;
transition: all .3s;
&:hover {
color: #DDD;
}
}
}
#icon {
display: inline-block;
padding-top: .7em;
font-size: 2em;
font-weight: 700;
text-transform: uppercase;
}
#nav-bg {
background: #222;
position: fixed;
height: 5em;
width: 100%;
top: 0;
z-index: 1;
}
header {
position: relative;
background-color: #FD7777;
padding: 10em 0 8em;
z-index: 2;
h1 {
font-size: 4em;
text-transform: uppercase;
text-align: center;
}
}
#about {
background: #E7E3DA;
height: 70em;
padding: 5em 0;
p {
line-height: 2em;
font-size: 1.4em;
margin: 0;
color: #222;
}
}
var header = $('header');
var range = 200;
$(window).on('scroll', function () {
var scrollTop = $(this).scrollTop(),
height = header.outerHeight(),
offset = height / 2,
calc = 1 - (scrollTop - offset + range) / range;
header.css({ 'opacity': calc });
if (calc > '1') {
header.css({ 'opacity': 1 });
} else if ( calc < '0' ) {
header.css({ 'opacity': 0 });
}
});
Also see: Tab Triggers