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.
<!-- info pulled from http://10mosttoday.com/10-most-beautiful-forests-in-the-world/ -->
<body ng-app='app' ng-controller='MainController'>
<main id='main'>
<section id='one'>
<div class='pane'
ng-repeat='forest in forests track by $index'
ng-if="$index == active">
<main>
<h1 ng-style="{'background-image' : 'url(' + forest.img + ')'}">{{ forest.rank }}</h1>
</main>
<div class="bg" ng-style="{'background-image' : 'url(' + forest.img + ')'}"></div>
</div>
</section>
<section id='two'>
<div class='pane'
ng-repeat='forest in forests track by $index'
ng-class="{ 'active' : $index == active }"
ng-if="$index == active">
<main>
<h2>{{ forest.name }}</h2>
<p>{{ forest.desc }}</p>
<p class='sub'>{{ forest.location }}</p>
</main>
</div>
</section>
</main>
<nav id='nav'>
<ul>
<li class="previous" ng-show="active > 0">
<a href='#' ng-click="previous()">
<span class='icon icon_arrow-left'></span>
</a>
</li>
<li class='numbers'>
<a href='#' ng-repeat="forest in forests track by $index" ng-click="setActive($index)" ng-class="{'active' : $index == active}">
{{ $index + 1 }}
</a>
</li>
<li class="next" ng-show="active + 1 < forests.length">
<a href='#' ng-click="next()">
<span class='icon icon_arrow-right'></span>
</a>
</li>
</ul>
</nav>
<div id="preloader">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/130891/sagano.jpg" alt="" />
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/130891/sequoia.jpg" alt="" />
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/130891/redwoods.jpg" alt="" />
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/130891/black-forest.jpg" alt="" />
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/130891/crooked-forest.jpg" alt="" />
</div>
</body>
@import "compass/css3";
@import "compass/reset";
@import "compass/css3";
/* Coolors Exported Palette - coolors.co/97dffc-858ae3-613dc1-4e148c-2c0735 */
$color1: #E26D5A;
$color2: #858ae3;
$color3: #613dc1;
$color4: #4e148c;
$color5: #2c0735;
// Grid
$line: 22px;
// Defaults
$default-transition-function: cubic-bezier(.65,.19,.08,.97);
$default-transition-duration: 0.5s;
// Typography
body {
background: lighten($color2, 27);
font-family: "ocr-b-std",sans-serif;
font-style: normal;
font-weight: 400;
color: lighten($color1, 25);
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4 {
font-family: "acta-display",sans-serif;
font-style: normal;
font-weight: 900;
color: $color5;
}
h1 {
@include single-transition(opacity, .5s);
opacity: .75;
background: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/130891/sagano.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
h2 { font-size: 56px; margin-bottom: $line; }
p {
font-size: 13px;
line-height: $line;
text-align: justify;
margin-bottom: $line;
}
.sub {
text-transform: uppercase;
font-size: 12px;
}
.icon {
font-size: 21px;
}
// Basic Layout
* { @include box-sizing(border-box); }
body, html { height: 100%; }
#main {
padding: 1em;
width: 100%;
height: 100%;
padding-bottom: $line*3;
margin-bottom: -$line*3;
}
#one, #two {
position: relative;
float: left;
height: 100%;
width: 50%;
overflow: hidden;
}
#one {
background: rgba(lighten($color2, 27), 1);
@include transition;
text-align: center;
.bg {
content: "";
background: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/130891/sagano.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
opacity: 0.75;
top: 0; left: 0; bottom: 0; right: 0;
position: absolute;
z-index: -1;
}
&:hover {
h1 { opacity: 0; }
background: rgba(lighten($color2, 27), 0);
}
h1 {
position: relative;
margin-top: -20px;
font-size: 750px;
font-size: 60vw;
}
}
@media (min-width: 1400px) {
#one h1 {
font-size: 838px;
}
}
#two {
background: lighten($color2, 27);
color: desaturate($color3, 40);
main { padding: 0 20% 0 2em; }
.pane {
&.active {
@include animation(fade-in $default-transition-duration*2 0 normal $default-transition-function);
}
}
}
// Panes
.pane {
top: 0;
display: flex;
height: 100%;
width: 100%;
position: absolute;
main {
margin: auto;
position: relative;
z-index: 1;
}
}
.pane.ng-enter, .pane.ng-leave {
@include transition;
}
#one .pane {
&.ng-leave,
&.ng-enter.ng-enter-active { top: 0; }
&.ng-enter { top: -100%; }
&.ng-leave.ng-leave-active { top: 100%; }
}
#two .pane {
&.ng-leave,
&.ng-enter.ng-enter-active { top: 0; }
&.ng-enter { top: 100%; }
&.ng-leave.ng-leave-active { top: -100%; }
}
// Navigation Bar
#nav {
position: relative;
overflow: hidden;
background: lighten($color2, 27);
width: 100%;
height: $line*3;
li {
position: absolute;
text-align: center;
a {
display: block;
padding: 0 1em;
color: $color5;
text-decoration: none;
height: $line*3;
line-height: $line*3;
.icon { line-height: $line*3; }
}
}
li.previous, li.next {
background: white;
width: 150px;
z-index: 2;
bottom: 0;
&.ng-hide-add.ng-hide-add-active,
&.ng-hide-remove.ng-hide-remove-active {
@include transition;
}
&.ng-hide {
bottom: -$line*3;
}
}
li.previous { left: 0; }
li.next { right: 0; }
li.numbers {
z-index: 0;
width: 100%;
margin: 0 auto;
left: 0; right: 0;
a {
display: inline;
&.active { color: $color2; }
}
}
}
@include keyframes(fade-in) {
0% { opacity: 0; }
100% { opactiy: 1; }
}
// Image Preloader
#preloader {
opacity: 0;
position: absolute;
z-index: -100;
width: 0; height: 0;
overflow: hidden;
}
angular.module('app', ['cfp.hotkeys', 'ngAnimate'])
.controller('MainController', function($scope, hotkeys) {
// functions
$scope.active = 0;
$scope.previous = function() {
if($scope.active != 0) $scope.active -= 1;
}
$scope.next = function() {
if($scope.active + 1 < $scope.forests.length) $scope.active += 1;
}
$scope.setActive = function(i) {
$scope.active = i;
}
$scope.forests = [
{
'rank' : 1,
'name' : 'Sagano Bamboo Forest',
'desc' : 'A magnificent Bamboo forest in the district of Arashiyama, west to Kyoto, Japan.',
'location' : 'Kyoto, Japan',
'img' : 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/130891/sagano.jpg'
},
{
'rank' : 2,
'name' : 'Giant Sequoia National Monument',
'desc' : 'Located in the southern Sierra Nevada mountains of California. The forest is named for the majestic Giant Sequoia trees which populate 38 distinct groves within the boundaries of the forest. The Sequoia National Forest covers 4,829 sq km (1,865 sq mi).',
'location' : 'California, United States',
'img' : 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/130891/sequoia.jpg'
},
{
'rank' : 3,
'name' : 'Redwood National Park',
'desc' : 'Also in California, The Redwood National parks is a combination of four parks that together protect 45% of all remaining coast redwood (Sequoia sempervirens) old-growth forests, totaling at least 158 square km. These trees are the tallest and one of the most massive tree species on Earth.',
'location' : 'California, United States',
'img' : 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/130891/redwoods.jpg'
},
{
'rank' : 4,
'name' : 'Black Forest',
'desc' : 'Schwarzwald or “Black Forest” is a wooded mountain range in Baden-Württemberg, southwestern Germany. It is bordered by the Rhine valley to the west and south. The name “Black Forest” was given by the Romans who referred to the forest blocking out most of the sunlight from getting inside the forest by the dense growth of conifers.',
'location' : 'Germany',
'img' : 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/130891/black-forest.jpg'
},
{
'rank' : 5,
'name' : 'Crooked Forest',
'desc' : 'A grove of oddly-shaped pine trees. This young forest was planted around 1930 and has about 400 pines. It is generally believed that some form of human tool or technique was used to make the trees grow this way, but the method and motive are not currently known. Some believe that the woods were deliberately grown this way to make “Compass Timbers”, or trees that are deliberately shaped for the purpose of using those odd shapes in ship building. Another theory is that tanks from WWII are the cause, rolling over the young trees snapping the stem, but still surviving, forcing them to grow in the direction they were ran over.',
'location' : 'Poland',
'img' : 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/130891/crooked-forest.jpg'
}
];
// hot keys
hotkeys.add({
combo: 'right',
description: 'Next slide',
callback: function() {
$scope.next();
}
});
hotkeys.add({
combo: 'left',
description: 'Previous slide',
callback: function() {
$scope.previous();
}
});
});
Also see: Tab Triggers