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.
<div class="pageWrapper">
<h2>Scroll your mouse over the map</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Justo nec ultrices dui sapien eget mi proin sed. In est ante in nibh mauris cursus mattis. Ut eu sem integer vitae justo eget magna fermentum. Elit pellentesque habitant morbi tristique. Eget aliquet nibh praesent tristique. Feugiat in fermentum posuere urna nec tincidunt praesent semper feugiat. Non odio euismod lacinia at quis risus sed. Mattis aliquam faucibus purus in massa tempor. Vitae congue eu consequat ac felis donec et odio pellentesque. Vivamus arcu felis bibendum ut tristique et egestas quis ipsum. Quis vel eros donec ac odio tempor.</p>
<p>Non consectetur a erat nam at lectus urna duis. Porttitor rhoncus dolor purus non. Id volutpat lacus laoreet non curabitur gravida arcu ac. Sapien pellentesque habitant morbi tristique senectus et. Elit ut aliquam purus sit amet. Eu facilisis sed odio morbi quis commodo. Et netus et malesuada fames. Tortor at auctor urna nunc id cursus. Pretium fusce id velit ut tortor pretium viverra suspendisse. Lorem sed risus ultricies tristique nulla aliquet enim tortor. Massa placerat duis ultricies lacus sed turpis tincidunt id. Malesuada proin libero nunc consequat. Fringilla urna porttitor rhoncus dolor purus non enim. Diam vulputate ut pharetra sit amet aliquam id diam maecenas. Mi ipsum faucibus vitae aliquet. Augue eget arcu dictum varius duis at consectetur. Malesuada proin libero nunc consequat interdum varius sit amet.</p>
<div id="viewDiv"></div>
<p>Porttitor eget dolor morbi non arcu risus quis varius. Sed odio morbi quis commodo odio. Dui id ornare arcu odio ut sem. Id interdum velit laoreet id donec ultrices tincidunt arcu. In nulla posuere sollicitudin aliquam ultrices sagittis orci a. Imperdiet sed euismod nisi porta lorem mollis. In nibh mauris cursus mattis molestie a. Integer quis auctor elit sed vulputate mi sit. Leo in vitae turpis massa sed elementum tempus. Cras ornare arcu dui vivamus arcu felis bibendum. Orci porta non pulvinar neque. Imperdiet sed euismod nisi porta lorem mollis. In nisl nisi scelerisque eu ultrices vitae auctor eu augue. A lacus vestibulum sed arcu non odio euismod lacinia at. Eget mauris pharetra et ultrices neque ornare aenean euismod. Eget mauris pharetra et ultrices neque ornare.</p>
<p> Libero volutpat sed cras ornare arcu dui vivamus arcu felis. Nam at lectus urna duis convallis convallis. Sed id semper risus in hendrerit. Odio eu feugiat pretium nibh ipsum consequat nisl. Molestie ac feugiat sed lectus vestibulum. Eu scelerisque felis imperdiet proin fermentum leo vel orci porta. Leo duis ut diam quam nulla porttitor massa id. Sed nisi lacus sed viverra tellus in hac. Nulla facilisi cras fermentum odio eu feugiat pretium nibh. In tellus integer feugiat scelerisque varius morbi enim. Tincidunt arcu non sodales neque sodales ut. Lorem ipsum dolor sit amet consectetur adipiscing elit duis. Risus sed vulputate odio ut enim blandit. Egestas quis ipsum suspendisse ultrices gravida dictum. Elit scelerisque mauris pellentesque pulvinar pellentesque habitant. Scelerisque mauris pellentesque pulvinar pellentesque habitant morbi tristique senectus. Quisque id diam vel quam elementum pulvinar etiam. Amet mattis vulputate enim nulla. Ante in nibh mauris cursus mattis molestie.</p>
<p>Faucibus nisl tincidunt eget nullam non nisi. Pulvinar etiam non quam lacus suspendisse faucibus. Amet purus gravida quis blandit turpis. Sit amet consectetur adipiscing elit pellentesque. Nunc sed blandit libero volutpat sed cras ornare. Metus aliquam eleifend mi in nulla posuere sollicitudin aliquam. Mattis aliquam faucibus purus in massa tempor nec feugiat. Sit amet commodo nulla facilisi. Ligula ullamcorper malesuada proin libero nunc consequat interdum varius sit. Est placerat in egestas erat imperdiet. Imperdiet massa tincidunt nunc pulvinar sapien et ligula. Mauris vitae ultricies leo integer malesuada nunc. At auctor urna nunc id cursus metus aliquam eleifend. Quam vulputate dignissim suspendisse in est. Facilisis leo vel fringilla est. Vestibulum lectus mauris ultrices eros in cursus. Viverra justo nec ultrices dui sapien eget mi. Urna molestie at elementum eu facilisis sed odio morbi. Quisque id diam vel quam. Consectetur a erat nam at lectus urna duis convallis.</p>
<p> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Eget sit amet tellus cras adipiscing. Risus pretium quam vulputate dignissim suspendisse in est ante. Nulla porttitor massa id neque aliquam vestibulum morbi blandit. Imperdiet massa tincidunt nunc pulvinar. Habitant morbi tristique senectus et netus. Odio ut sem nulla pharetra diam sit. Morbi tincidunt augue interdum velit euismod in. Tristique et egestas quis ipsum suspendisse ultrices gravida dictum. Vel eros donec ac odio tempor orci dapibus ultrices in. Egestas integer eget aliquet nibh praesent tristique magna. Magnis dis parturient montes nascetur ridiculus mus mauris. Fusce ut placerat orci nulla pellentesque dignissim enim. Ornare arcu odio ut sem nulla. In pellentesque massa placerat duis ultricies lacus sed.</p>
<p>Ut consequat semper viverra nam libero justo. Vel turpis nunc eget lorem dolor. Magnis dis parturient montes nascetur ridiculus. Convallis tellus id interdum velit. Tortor id aliquet lectus proin nibh nisl condimentum id venenatis. In cursus turpis massa tincidunt dui ut. Mauris rhoncus aenean vel elit scelerisque mauris. Nec feugiat nisl pretium fusce. Leo in vitae turpis massa sed. Tellus rutrum tellus pellentesque eu tincidunt tortor aliquam nulla facilisi. Eu facilisis sed odio morbi quis. Suspendisse faucibus interdum posuere lorem ipsum dolor. Eu lobortis elementum nibh tellus molestie nunc non blandit. Amet venenatis urna cursus eget nunc scelerisque viverra. Molestie at elementum eu facilisis sed odio. Sed elementum tempus egestas sed sed risus pretium quam. Penatibus et magnis dis parturient montes nascetur ridiculus mus mauris.</p>
<p>Adipiscing enim eu turpis egestas pretium. Mauris ultrices eros in cursus. Maecenas sed enim ut sem viverra aliquet eget sit amet. Porttitor massa id neque aliquam vestibulum morbi blandit. Gravida rutrum quisque non tellus orci. Justo donec enim diam vulputate ut pharetra. Blandit cursus risus at ultrices. Vitae congue mauris rhoncus aenean vel elit scelerisque mauris pellentesque. Aenean euismod elementum nisi quis eleifend. Ac odio tempor orci dapibus. Donec enim diam vulputate ut. Quis blandit turpis cursus in. Turpis egestas sed tempus urna et. Adipiscing diam donec adipiscing tristique risus nec feugiat in fermentum. Elit ullamcorper dignissim cras tincidunt lobortis feugiat vivamus at augue. Sit amet nisl suscipit adipiscing bibendum est. Eleifend quam adipiscing vitae proin sagittis nisl rhoncus mattis rhoncus. Tempor orci dapibus ultrices in iaculis nunc.</p>
<p>Egestas purus viverra accumsan in nisl nisi scelerisque. Fames ac turpis egestas maecenas pharetra convallis. Quam nulla porttitor massa id neque aliquam vestibulum. Urna et pharetra pharetra massa. Egestas purus viverra accumsan in nisl. Blandit massa enim nec dui nunc mattis. Id neque aliquam vestibulum morbi blandit cursus. Pretium viverra suspendisse potenti nullam ac. Leo integer malesuada nunc vel risus commodo viverra. Sed velit dignissim sodales ut eu sem. Consectetur adipiscing elit duis tristique sollicitudin nibh sit amet. Aliquam eleifend mi in nulla posuere sollicitudin. Leo urna molestie at elementum eu facilisis sed. Nullam eget felis eget nunc lobortis mattis aliquam faucibus.</p>
<p>Lobortis scelerisque fermentum dui faucibus in ornare quam. Ornare arcu dui vivamus arcu felis. Sollicitudin ac orci phasellus egestas tellus rutrum tellus pellentesque. Ipsum dolor sit amet consectetur adipiscing elit duis tristique. Enim neque volutpat ac tincidunt vitae semper. Non quam lacus suspendisse faucibus interdum. Egestas congue quisque egestas diam. Non arcu risus quis varius. Quis commodo odio aenean sed adipiscing diam donec adipiscing. Metus vulputate eu scelerisque felis imperdiet proin fermentum leo vel. Nibh sit amet commodo nulla facilisi nullam vehicula. Ornare arcu dui vivamus arcu felis bibendum.</p>
</div>
html,
body {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
#viewDiv{
width: 400px;
height: 400px;
float: right;
position: relative; /* important for the overlay to work! */
}
.overlayDiv {
position: absolute;
z-index: 2;
height: 100%;
width: 100%;
background-color: rgba(0,0,0,0.45);
text-align: center;
pointer-events: none;
transition: opacity 0.8s ease-in-out;
}
.overlayDiv > p {
color: white;
font-size: 22px;
position: relative;
margin: 0;
top: 50%;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}
.overlayDiv.hidden {
opacity: 0;
}
require([
"esri/Map",
"esri/views/SceneView",
"esri/views/MapView",
"dojo/domReady!"
], function(Map, SceneView, MapView) {
var map = new Map({
basemap: "streets-vector"
});
var viewOptions = {
container: "viewDiv",
map: map,
center: [-101.17, 21.78],
zoom: 2
};
// 2D:
// var view = new MapView(viewOptions);
// 3D:
var view = new SceneView(viewOptions);
view.when(function() {
initializeOverlay(viewOptions.container);
// setup "whell scroll" listener on the map
// code from
// https://community.esri.com/thread/177970#comment-612463
view.surface.addEventListener(
"wheel",
function(event) {
if(!event.ctrlKey) {
event.stopImmediatePropagation();
showZoomMessage();
} else {
event.preventDefault();
overlayDiv.classList.add("hidden");
}
},
true
);
});
var overlayDiv;
function initializeOverlay(domNodeId) {
overlayDiv = document.createElement("div");
overlayDiv.innerHTML = "<p>Use ctrl + scroll to zoom the map</p>";
overlayDiv.className = "overlayDiv hidden";
view.container.appendChild(overlayDiv);
}
var timeout;
function showZoomMessage() {
// For the case where we already have a timeout,
// We want to EXTEND the message to show another 2 seconds
// so cancel the previous timeout before setting up a new one.
if (timeout) {
window.clearTimeout(timeout);
}
overlayDiv.classList.remove("hidden");
timeout = setTimeout(function() {
overlayDiv.classList.add("hidden");
}, 1500);
}
});
Also see: Tab Triggers