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.
<article id="example">A scrollbar is a graphical control element with which continuous text, pictures or anything else can be scrolled including time in video applications, i.e., viewed even if it does not fit into the space in a computer display, window, or viewport. It was also known as a handle in the very first GUIs.
Scrollbars are present in a wide range of electronic devices including computers, graphing calculators, mobile phones, and portable media players. They usually appear on one or two sides of the viewing area as long rectangular areas containing a bar (or thumb) that can be dragged along a trough (or track) to move the body of the document as well as two arrows on either end for precise adjustments. The "thumb" has different names in different environments: on the Macintosh it is called a "scroller";[1] on the Java platform it is called "thumb" or "knob"; Microsoft's .NET documentation refers to it as "scroll box" or "scroll thumb"; in other environments it is called "elevator", "quint", "puck", "wiper" or "grip". Additional functions may be found, such as zooming in/out or various application-specific tools. Depending on the graphical user interface, the size of the thumb can be fixed or variable in size; in the later case of proportional thumbs, its length would indicate the size of the window in relation to the size of the whole document. While proportional thumbs were available in several GUIs including GEM, AmigaOS and PC/GEOS even in the early 1980s, Microsoft provided them not before the release of Windows 95. A proportional thumb that completely fills the trough indicates that the entire document is being viewed, at which point the scrollbar may temporarily become hidden. The proportional thumb can also sometimes be adjusted by dragging its ends. In this case it would adjust both the position and the zooming of the document, where the size of the thumb represents the degree of zooming applied.</article>
body {
background-color: #C851E8;
}
#example {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 300px;
height: 300px;
border:1px #FFC2E9 solid;
border-radius: 4px;
padding: 10px;
}
*.-morulus-customsb {
position:relative;
width:100%;
height:100%;
overflow:hidden;
}
*.-morulus-customsb > figure:first-child {
margin: 0px !important;
position: absolute;
right: 4px !important;
width: 4px !important;
height: 100px;
background-color: #FFC2E9;
}
*.-morulus-customsb > *:last-child {
overflow-y: scroll;
height: 100%;
width: 100%;
padding-right: 20px;
}
// Perform custom scrollbar
window.morulusCustomSb = (function() {
var nu=navigator.userAgent,
aus=['Mozilla','IE'],
// Remove event listner polyfill
removeEventListner = function(el, type, handler) {
if ( el.addEventListener ) {
el.removeEventListener(type, handler, false);
} else if ( elem.attachEvent ) {
el.detachEvent("on" + type, handler);
} else {
el["on"+type] = null;
};
},
// Event listner polyfill
eventListner = function(el, type, handler, once) {
var realhandler = once ? function() {
removeEventListner(el, type, realhandler);
} : handler;
if ( el.addEventListener ) {
listen = el.addEventListener( type, handler, false );
} else if (el.attachEvent) {
listen = el.addEventListener( 'on'+type, handler, false );
} else {
el['on'+type] = handler;
}
return el;
},
retfalse = function() { return !!0; },
disableSelection = function(el) {
if (nu.indexOf(aus[0]) != -1) // FF
el.style['MozUserSelect']='none';
else if (nu.indexOf(aus[1]) != -1) // IE
eventListner(el, 'selectstart.disableTextSelect', retfalse);
else
eventListner(el, 'mousedown.disableTextSelect', retfalse);
},
enableSelection = function(el) {
if (nu.indexOf(aus[0]) != -1) // FF
el.style['MozUserSelect']='';
else if (nu.indexOf(aus[1]) != -1) // IE
removeEventListner(el, 'selectstart.disableTextSelect', retfalse);
else
removeEventListner(el, 'mousedown.disableTextSelect', retfalse);
}
return function(a) {
var
listen,
i,
d=document,
s, // Scrollable
n, // Custom scrollbar wrapper
r, // Runner
height, // Runner height
scrollTop, // Start scroll top,
// Scroll handler
handlerScroll = function(e) {
r.style.top = ( (100 - parseInt(r.style.height)) * (s.scrollTop/(s.scrollHeight-s.clientHeight)) )+'%';
},
drag = !!0,
screenY = 0,
handlerMove = function(e) {
var d = ((height*(scrollTop/(s.scrollHeight-s.clientHeight)))+(e.screenY-screenY));
if (d>height) d = height;
else if (d<0) d = 0;
// set Scroll top
s.scrollTop = Math.round((s.scrollHeight-s.clientHeight)*(d/height));
},
handlerUp = function(e) {
drag=!!0;
// Enable selection
enableSelection(s);
// remove listen for window move
removeEventListner(window, 'mousemove', handlerMove);
e.stopPropagation();
},
handlerDown = function(e) {
drag=!0;screenY=e.screenY;
height=s.clientHeight-parseInt(window.getComputedStyle(r).height);
scrollTop=s.scrollTop;
// Disable selection
disableSelection(s);
// Listen for window move
eventListner(window, 'mousemove', handlerMove);
eventListner(window, 'mouseup', handlerUp, true);
e.preventDefault();
return false;
},
handlerWrapDown = function(e) {
if(e.offsetX>n.offsetWidth-20){
s.scrollTop = Math.round((s.scrollHeight-s.clientHeight)*(e.offsetY/n.offsetHeight));
handlerDown(e);
}
},
n=d.createElement('div');
r=d.createElement('figure');
s=d.createElement('div');
// Wrap each insert elements
for (i=0;i<a.childNodes.length;i++) {
s.appendChild(a.childNodes[0]);
}
a.appendChild(n);
n.appendChild(r);
n.appendChild(s);
n.className = '-morulus-customsb';
// Set size of runner
r.style.height = (100*(s.clientHeight/s.scrollHeight)
.toFixed(2))+'%';
// Listen for scroll
eventListner(s,'scroll',handlerScroll);
// Listen for drug
eventListner(r,'mousedown',handlerDown);
eventListner(r,'mouseup',handlerUp);
// Listerb for drug on wrapper
eventListner(n,'mousedown',handlerWrapDown);
};
})();
// Execute
morulusCustomSb(document.getElementsByTagName('article')[0])
Also see: Tab Triggers