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 URL's 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 it's URL and the proper URL extention.
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 Skypack, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ES6 import
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.
<main>
<section>
<h1 class="grid">
<span class="title1">
<span>Women</span><br /> of</span>
<span class="title2">Atomic Physics</span>
</h1>
</section>
<section>
<div class="grid">
<h2>Vera Rubin</h2>
<div class="dates"><time datetime="1928">1928</time> – <time datetime="2016">2016</time></div>
<div class="body-text">
<p>Vera Rubin was an American astronomer who pioneered work on galaxy rotation rates. She uncovered the discrepancy between the predicted angular motion of galaxies and the observed motion, by studying galactic rotation curves. This phenomenon became known as the galaxy rotation problem, and was evidence of the existence of dark matter. Although initially met with skepticism, Rubin's results were confirmed over subsequent decades. Her legacy was described by The New York Times as "ushering in a Copernican-scale change" in cosmological theory.</p>
</div>
</div>
</section>
<section>
<div class="grid">
<h2>Maria Goeppert Mayer</h2>
<div class="dates"><time datetime="1906">1906</time> – <time datetime="1972">1972</time></div>
<div class="body-text">
<p>Maria Goeppert Mayer was a German-born American theoretical physicist, and Nobel laureate in Physics for proposing the nuclear shell model of the atomic nucleus. She was the second woman to win a Nobel Prize in physics In 1986, the Maria Goeppert-Mayer Award for early-career women physicists was established in her honor.</p>
<p>She developed a mathematical model for the structure of nuclear shells, for which she was awarded the Nobel Prize in Physics in 1963, which she shared with J. Hans D. Jensen and Eugene Wigner.</p>
</div>
</div>
</section>
<section>
<div class="grid">
<h2>Fabiola Gianotti</h2>
<div class="dates">Born <time datetime="1960">1960</time></div>
<div class="body-text">
<p>Fabiola Gianotti is an Italian experimental particle physicist, and the first woman to be Director-General at CERN in Switzerland. Since 1994 she has been a research physicist at CERN, and since August 2013 an honorary Professor at the University of Edinburgh. Dr Gianotti has worked on several CERN experiments, and been involved in detector R&D, construction, software development and data analysis.</p>
<p>At its 195th Session, the CERN Council selected Fabiola Gianotti, as the Organization’s next Director-General. This is the first time in CERN’s history that a Director-General has been appointed for a full second term.</p>
</div>
</div>
</section>
<section>
<div class="grid">
<h2>Lise Meitner</h2>
<div class="dates"><time datetime="1878">1878</time> – <time datetime="1968">1968</time></div>
<div class="body-text">
<p>Lise Meitner was an Austrian-Swedish physicist who worked on radioactivity and nuclear physics. Meitner, Otto Hahn and Otto Robert Frisch led the small group of scientists who first discovered nuclear fission of uranium when it absorbed an extra neutron. She was the first woman to become a full professor of physics in Germany.</p><p>She was invited to work on the Manhattan Project (1942–45) in the United States, but she opposed the atomic bomb, and rejected the offer.</p>
</div>
</div>
</section>
</main>
@import url('https://fonts.googleapis.com/css?family=Merriweather|Titillium+Web:700&display=swap');
$md: 50em;
* {
box-sizing: border-box;
}
body {
font-family: 'Merriweather', serif;
line-height: 1.6;
margin: 0;
}
main {
height: 100vh;
overflow-y: scroll;
scroll-snap-type: y mandatory;
}
section {
min-height: 100vh;
padding: 1rem;
display: flex;
justify-content: center;
align-items: center;
scroll-snap-align: start;
@media (min-width: $md) {
padding: 2rem;
}
.grid > * {
opacity: 0;
transform: translate3d(-2rem, 0, 0);
transition: opacity 700ms var(--delay, 0ms), transform 700ms var(--delay, 0ms);
}
&.is-visible {
.grid > * {
opacity: 1;
transform: translate3d(0, 0, 0);
}
}
}
h2,
p,
h1 {
margin: 0;
}
p + p {
margin-top: 1rem;
}
h1,
h2 {
font-family: 'Titillium Web', sans-serif;
line-height: 1;
letter-spacing: -0.03em;
}
h1 {
font-size: 3rem;
}
.title1 {
grid-column: 1 / 3;
grid-row: 1 / -3;
text-align: right;
margin-bottom: 1rem;
border-right: 4px solid;
padding-right: 1rem;
span:first-child {
@media (min-width: $md) {
font-size: 5rem;
}
}
}
.title2 {
font-size: 7rem;
line-height: 0.9;
grid-column: 3 / -1;
grid-row: 3 / -1;
align-self: center;
@media (min-width: $md) {
font-size: 11rem;
}
}
h2 {
font-size: 4rem;
grid-column: 1 / span 3;
grid-row: 3 / -1;
@media (min-width: $md) {
font-size: 9rem;
}
}
.grid {
@media (min-width: $md) {
display: grid;
grid-template-columns: 3fr 2fr 1fr 3fr 1fr 2fr 3fr;
grid-template-rows: 2fr 2fr 1fr 1fr 2fr 2fr;
gap: 1rem;
width: 60rem;
max-width: 100%;
}
&::after {
content: '';
grid-area: 2 / 2 / -2 / -2;
background-color: aquamarine;
z-index: -1;
}
}
.body-text {
grid-column: 4 / -1;
grid-row: 1 / 5;
}
.dates {
font-size: 2rem;
grid-column: 3 / 6;
grid-row: 5;
}
section {
&:nth-child(2) {
.grid {
&::after {
background-color: salmon;
}
}
h2 {
align-self: flex-end;
}
}
&:nth-child(3) {
.grid {
&::after {
background-color: plum;
}
}
h2 {
grid-column: 3 / -1;
grid-row: 2 / -1;
text-align: right;
}
.body-text {
grid-column: 1 / 5;
grid-row: 1 / 6;
}
.dates {
grid-column: 3 / 5;
grid-row: -2;
text-align: right;
}
}
&:nth-child(4) {
.grid {
&::after {
background-color: darkTurquoise;
}
}
h2 {
grid-column: 1 / 6;
grid-row: 1 / 3;
}
.body-text {
grid-column: 4 / -1;
grid-row: 4 / -1;
}
.dates {
grid-column: 2 / 4;
grid-row: 3;
text-align: right;
}
}
&:nth-child(5) {
.grid {
&::after {
background-color: mediumslateblue;
}
}
h2 {
grid-column: 3 / -1;
grid-row: 1 / 4;
text-align: right;
}
.body-text {
grid-column: 1 / 5;
grid-row: 5 / -1;
}
.dates {
grid-column: 5 / -1;
grid-row: 4;
}
}
}
const sections = [...document.querySelectorAll("section")]
let options = {
rootMargin: "0px",
threshold: 0.25
}
const callback = (entries, observer) => {
entries.forEach(entry => {
const { target } = entry
if (entry.intersectionRatio >= 0.25) {
target.classList.add("is-visible")
} else {
target.classList.remove("is-visible")
}
})
}
const observer = new IntersectionObserver(callback, options)
sections.forEach((section, index) => {
const sectionChildren = [...section.querySelector('.grid').children]
sectionChildren.forEach((el, index) => {
el.style.setProperty('--delay', `${index * 100}ms`)
})
observer.observe(section)
})
Also see: Tab Triggers