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.
<img src="https://images.unsplash.com/photo-1441974231531-c6227db76b6e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1051&q=80">
<article class="body-content">
<div class="prl-narrow-container">
<p>Building on years of breaktrough research, Michigan State University biochemist <a href="/people/faculty/thomas-d-sharkey/">Thomas Sharkey</a> has received a four-year, $898,946 grant from the National Science Foundation (NSF) to continue his research on isoprene emission from plants. The four-year grant will focus on the evolutionary pattern of the appearance and loss of isoprene emission among various land plants, and the impact of these emissions have on the atmosphere.</p>
<p>Isoprene is a gas molecule given off by many trees, ferns and mosses. The relatively frequent gain and loss of isoprene emissions and its scattered distribution among land plants indicates that the trait is constantly in an evolutionary balancing act, enhancing plant resilience and fitness, but at some cost to the plant. The question facing scientists is: What is it that triggers the coming and going of this trait?</p>
<p>Scientists are yet to fully understand the benefits plants get by making isoprene. What they know so far is that isoprene has been shown to enhance plant tolerance of heat, oxidative stress, and ward off insects that feed on them. Understanding isoprene emission in plants is important for determining if or when it might be useful to engineer crops to make it, or to engineer emitting plants to suppress it.</p>
<p>“We think the benefits and costs to plants of making isoprene are very nearly balanced,” said Sharkey, a University Distinguished Professor at the <a href="/">MSU-DOE Plant Research Laboratory</a> and member of the <a href="https://bmb.natsci.msu.edu/">Department of Biochemistry & Molecular Biology</a> at the <a href="https://natsci.msu.edu/">College of Natural Sciences</a>. “For some plants, the balance favors isoprene emission, while others are on the cost side of the tipping point. This work will give a much clearer picture of the cost-benefit balance and will help us understand this very important molecule.”</p>
<p>It is also critically important to understand these isoprene emissions because they are a major concern in atmospheric chemistry, contributing to tropospheric ozone formation (the bad ozone, precursor to smog), aerosols and formaldehyde, especially in atmospheres polluted with nitrogen oxide. Plants, particularly trees, emit significant amounts of isoprene into the atmosphere. Because of this, atmospheric modelers need to know how much isoprene is emitted from vegetation and how this may change in the future.</p>
<p>“We believe that a thorough understanding of the forces that shape the evolutionary history of isoprene emission from plants will improve future global emission estimates,” said Sharkey, who also serves as Associate Director with MSU’s <a href="https://plantresilience.msu.edu/">Plant Resilience Institute</a>.</p>
<p>The study has three primary aims: to investigate the benefits of isoprene emission, the costs of isoprene emission and the genetic mechanisms that isoprene may coopt to relgulate the rate of synthesis and resilience toward plant stress. The overall goal of the research is to determine which specific evolutionary constraints are responsible for selecting for maintenance of isoprene emission in plants and those that favor the loss of the trait.</p>
<p>The scientists will focus on three plants. Two are non isoprene-producing plants, <em>Arabidopsis thaliana</em> and tobacco, that have been engineered to make isoprene. The third plant, poplar, makes a lot of isoprene, but has been engineered to stop making the molecule.</p>
<p>“Information gained from this study will enable us to understand receptors and pathways in plants that facilitate the signaling process of isoprene and how isoprene signaling ‘cross-talks’ with other well-known growth and stress-repsonsive signaling pathways,” Sharkey said. “Knowledge of the dominant evolutionary constraints and factors that enhance the likelihood of isoprene-forming enzymes will enable us to predict the evolutionary trend of isoprene emission in response to climate change.”</p>
<p>Research on isoprene is also of interest to the the biotech industry. A number of projects are aiming to convert it into a source of biofuels or industrial raw materials. New insights from the <a href="https://bmb.natsci.msu.edu/faculty/thomas-d-sharkey/sharkey-lab/">Sharkey lab</a> could help bioengineer better sources of isoprene.</p>
<p>An important component of this research is the inclusion of students participating in the <a href="https://plantgenomics.natsci.msu.edu/">MSU Plant Genomics REU Program</a>, which provides high quality research and training programs for underrepresented undergraduate students interested in biochemistry, bioinformatics, biology, biotechnology, chemistry and computational sciences. Several of these students have been involved in isoprene-related projects and have been co-authors on publications from Sharkey’s lab.</p>
<p>“This program is an excellent resource to inspire and train a future workforce that is diverse and globally competitive,” Sharkey said.</p>
<p>Another goal of the program is to improve public scientific literacy. Sharkey and his team will participate in <a href="https://msutoday.msu.edu/news/2019/msu-hosts-2019-fascination-of-plants-day/">MSU’s Fascination of Plants Day</a>—a worldwide event that aims to enthuse the public about the importance of plant science in everyday– and the <a href="file:///C:/Users/houwatig/AppData/Local/Microsoft/Windows/INetCache/Content.Outlook/FE2FW65H/a%20worldwide%20event%20promoted%20by%20the%20European%20Plant%20Science%20Organization.%20It%20aims%20to%20enthuse%20the%20public%20about%20the%20importance%20of%20plant%20science%20in%20everyday–">MSU Science Festival</a> to share information on their research.</p>
<hr>
<p class="prl-news-support-tag"><small>Banner image: Plants, particularly trees, emit significant amounts of isoprene into the atmosphere. The lab of Thomas Sharkey will study the evolutionary pattern of the appearance and loss of isoprene emission among various land plants and the impact these emissions have on the atmosphere. Image by Diliff, <a href="https://commons.wikimedia.org/w/index.php?curid=234811">CC BY-SA 2.5</a>.</small></p>
</div>
</article>
<div class="extra-bottom-part">
<h2>Extra section not factored in for progress bar</h2>
<p>What is Lorem Ipsum?
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
<p>What is Lorem Ipsum?
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</div>
body {
height: 150vh;
font-family: Arial, sans-serif;
}
img {
position: relative;
display: inline-block;
height: 500px;
width: 100%;
}
article p {
margin: 20px auto;
max-width: 600px;
padding: 0 8px;
}
.extra-bottom-part {
position: relative;
margin: 40vh 0;
}
.prl-progress-bar {
position: fixed;
z-index: 100;
height: 12px;
bottom: 0;
transition: 0.2s;
transition-property: width;
transition-timing-function: ease-out;
background-color: rgba(46,77,77, 1); // PRL green
}
addProgressBarElement = () => {
progressBar = document.createElement('div');
progressBar.className = ('prl-progress-bar');
progressBar.setAttribute('aria-hidden', 'true');
progressBar.style.width = '0%';
document.body.prepend(progressBar)
}
// Approach 1. Scroll method (currently calculates entire)
// window.onload = () => { addProgressBarElement() }
// window.onscroll = () => { progressBarProgression() }
// window.onresize = () => { progressBarProgression() }
// progressBarProgression = (event) => {
// progressBar = document.body.querySelector('.prl-progress-bar');
// pixelsScrolled = window.scrollY;
// totalDocumentHeight = document.body.scrollHeight;
// viewportHeight = window.innerHeight
// currentScrollPosition = (pixelsScrolled / (totalDocumentHeight - viewportHeight))*100
// progressBar.style.width = currentScrollPosition + "%"
// }
// Approach 2. Intersection observer method
calculateProgressBarProgression = () => {
const progressBar = document.body.querySelector('.prl-progress-bar');
const pageParts = Array.from(document.querySelectorAll('article > .prl-narrow-container > *'))
console.log('sections to calculate progress bar', pageParts)
let observer = new IntersectionObserver(entries => {
entries.forEach(entry => {
if(entry.intersectionRatio === 1){
pagePartsIndex = pageParts.indexOf(entry.target) + 1
percentageScrolled = (pagePartsIndex / pageParts.length)*100
progressBar.style.width = percentageScrolled + "%"
}
})
}, {threshold: 1});
pageParts.forEach(part => observer.observe(part))
}
window.onload = () => { addProgressBarElement(), calculateProgressBarProgression() }
window.onresize = () => { calculateProgressBarProgression() }
// Todo:
// DONE Listen to page scroll
// DONE Determine document position on page scroll
// DONE Add progress bar to document on page load
// DONE Style progress bar in CSS
// DONE Change progress bar width in relation to doc
// DONE Add code to Codepen
Also see: Tab Triggers