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.
.main-content
input(type="radio" id="about" name="pages" checked)
label(for="about") Lin-Manuel Miranda
input(type="radio" id="awards" name="pages" )
label(for="awards") EGOT Awards
input(type="radio" id="book" name="pages")
label(for="book") Motivational Speaker
.profile-content
.profile-name Lin-Manuel Miranda
.profile-pic
img(src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/567707/lmm.png" alt="LMM")
.item.page-1.intro Lin-Manuel Miranda is an award-winning composer, lyricist, and performer.
.item.page-1.hamilton
img(src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/567707/hamilton.png" alt="Hamilton")
.item.page-1.moana
img(src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/567707/moana.png" alt="Moana")
.item.page-1.ith
img(src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/567707/ith.png" alt="In The Heights")
.item.page-1.chump
img(src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/567707/chump.png" alt="21 Chump Street")
.item.page-1.bringiton
img(src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/567707/bringiton.png" alt="Bring It On")
.item.page-2.intro
| Lin-Manuel Miranda has won many awards. But he is not an EGOT winner...
em yet
|.
.item.page-2.emmy
.subitem
.trophy Emmy's
.list
- var emmyawards = [{ recipient: "\"Bigger!\" (from 67th Tony Awards)", title: "Outstanding Original Music and Lyrics", year: "2014"}]
each val in emmyawards
.list_item
.award-recipient= val.recipient
.award-title
span= val.title
span.award-year= val.year
.item.page-2.grammy
.subitem
.trophy Grammy's
.list
- var grammyawards = [{ recipient: "\"How Far I'll Go\" (from Moana)", title: "Best Song Written for Visual Media", year: "2018"},{ recipient: "Hamilton", title: "Best Musical Theater Album", year: "2016"},{ recipient: "In the Heights", title: "Best Musical Theater Album", year: "2009"}]
each val in grammyawards
.list_item
.award-recipient= val.recipient
.award-title
span= val.title
span.award-year= val.year
.item.page-2.oscar
.subitem
.trophy Oscar's
.coming-soon
em Coming Soon
.item.page-2.tony
.subitem
.trophy Tony's
.list
- var tonyawards = [{ recipient: "Hamilton", title: "Best Book of a Musical", year: "2016"},{ recipient: "Hamilton", title: "Best Original Score", year: "2016"},{ recipient: "In the Heights", title: "Best Original Score", year: "2008"}]
each val in tonyawards
.list_item
.award-recipient= val.recipient
.award-title
span= val.title
span.award-year= val.year
.item.page-3.intro Lin-Manuel Miranda wrote so many motivational tweets, they made it into a book.
.item.page-3.book
img(src="https://images.penguinrandomhouse.com/cover/9781984854278" alt="Gmorning, Gnight! book")
.item.page-3.book-info
.subitem
h5.title
| Gmorning, Gnight!:
br
| Little Pep Talks for Me & You
p
span 200 pages of concise pieces of advice with which to start or end the day.
//aside.context
.explanation
| Some kind of explanation that is
a(href="" target="_blank") interesting here
| .
//footer
a(href="https://twitter.com/meowlivia_" target="_blank")
i.icon-social-twitter.icons
a(href="https://github.com/oliviale" target="_blank")
i.icon-social-github.icons
a(href="https://dribbble.com/oliviale" target="_blank")
i.icon-social-dribbble.icons
body {
background: #f1f5f6;
font-family: "Noticia Text", sans-serif;
}
em {
font-style: italic;
}
aside.context {
text-align: center;
color: #fff;
line-height: 1.7;
a {
text-decoration: none;
color: #fff;
padding: 3px 0;
border-bottom: 1px dashed;
&:hover {
border-bottom: 1px solid;
}
}
.explanation {
max-width: 700px;
margin: 6em auto 0;
}
}
footer {
text-align: center;
margin: 4em auto;
width: 100%;
a {
text-decoration: none;
display: inline-block;
width: 45px;
height: 45px;
border-radius: 50%;
background: transparent;
border: 1px dashed #fff;
color: #fff;
margin: 5px;
&:hover {
background: rgba(255, 255, 255, 0.1);
}
.icons {
margin-top: 12px;
display: inline-block;
font-size: 20px;
}
}
}
* {
box-sizing: border-box;
}
.main-content {
max-width: 1200px;
margin: auto;
}
.profile-content {
width: 100%;
min-height: 140vh;
overflow-y: hidden;
padding: 4em;
display: grid;
margin: auto;
grid-template-columns: repeat(11, 1fr);
grid-template-rows: 250px repeat(3, 1fr);
}
input {
display: none;
&:checked + label {
font-weight: 700;
&:before {
height: 13px;
}
}
}
label {
position: absolute;
margin-top: 20px;
top: 20px;
left: 3em;
padding-left: 1em;
cursor: pointer;
background: #f1f5f6;
z-index: 20;
&:before {
content: '';
background: #000;
width: 13px;
transition: .2s ease;
height: 0;
top: 2px;
position: absolute;
left: -3px;
}
&[for="awards"] {
top: 40px;
}
&[for="book"] {
top: 60px;
}
}
/* controlling items */
.item {
max-height: 800px;
transition: all .4s ease;
overflow: hidden;
opacity: 1;
position: relative;
z-index: 10;
width: 100%;
&.page-1 {
img {
width: 100%;
height: 100%;
object-fit: contain;
position: relative;
z-index: 10;
transition: .4s ease;
}
}
}
.subitem {
transition: .4s ease-in-out .3s;
opacity: 0;
position: relative;
top: 15px;
}
#about:checked ~ .profile-content {
.page-2,
.page-3 {
max-height: 0;
width: 0;
opacity: 0;
}
}
#awards:checked ~ .profile-content {
.page-1,
.page-3 {
max-height: 0;
width: 0;
opacity: 0;
}
.page-2 .subitem {
opacity: 1;
top: 0;
}
}
#book:checked ~ .profile-content {
.page-1,
.page-2 {
width: 0;
max-height: 0;
opacity: 0;
}
.page-3 .subitem {
opacity: 1;
top: 0;
}
}
/* specfiic items */
.hamilton {
grid-column: 3 / span 4;
grid-row: 2 / span 3;
}
.chump {
grid-column: 2 / span 2;
grid-row: 4 / span 1;
}
.ith {
grid-column: 7 / span 3;
grid-row: 1 / span 3;
margin-top: 3em;
}
.moana {
grid-column: 1 / span 2;
grid-row: 1 / span 2;
margin-top: 10em;
}
.bringiton {
grid-row: 3 / span 2;
grid-column: 10 / span 2;
}
.profile-name {
font: 120px/1 "Mr Dafoe", cursive;
color: #e6e6e6;
grid-row: 1 / span 1;
grid-column: 1 / span 11;
text-align: right;
}
.profile-pic {
img {
position: fixed;
top: 0;
right: 2%;
height: 180%;
width: auto;
z-index: 1;
}
}
.intro {
grid-row: 1 / span 1;
grid-column: 1 / span 8;
margin-top: 3.5em;
font: 28px/1.3 'Noticia Text', serif;
}
.book {
grid-row: 2 / span 3;
grid-column: 1 / span 3;
margin-top: -4em;
img {
width: 100%;
object-fit: cover;
margin-top: 40px;
}
}
.book-info {
grid-row: 2 / span 4;
grid-column: 4 / span 5;
margin: 2.5em 0 0 4em;
align-items: center;
}
h5.title {
font: 700 30px/1.1 "Noticia Text", serif;
color: #000;
width: 85%;
}
p {
font: 400 20px/1.5 "Noticia Text", serif;
color: #555;
margin-top: 20px;
width: 80%;
}
.list {
padding-right: 3em;
}
.list_item {
line-height: 1.4;
padding: 10px 0;
.award-recipient {
font-size: 18px;
}
.award-title {
color: #999;
margin-top: 3px;
}
.award-year {
color: #999;
display: inline-block;
position: relative;
margin-left: 15px;
&:after {
content: "●";
position: absolute;
font-size: 8px;
left: -10px;
top: 5px;
}
}
}
.trophy {
font: italic 700 24px/1 'Noticia Text', serif;
margin-bottom: 1em;
}
.emmy {
grid-column: 1 / span 3;
grid-row: 2 / span 4;
}
.grammy {
grid-column: 4 / span 3;
grid-row: 2 / span 4;
}
.oscar {
grid-column: 1 / span 2;
grid-row: 3 / span 4;
margin-top: 1em;
.trophy {
margin-bottom: 1.5em;
}
}
.tony {
grid-column: 7 / span 3;
grid-row: 2 / span 4;
}
@media screen and (max-width: 1000px) {
.profile-content {
grid-auto-fill: dense;
max-height: none;
grid: min-content repeat(5, max-content) / 35% 35% 30%;
}
.intro {
grid-column: 1 / span 2;
margin: 3em 0 2em;
}
.profile-name {
font: 100px/1 "Mr Dafoe", cursive;
}
.profile-pic img {
right: -2%;
height: 100%;
}
.page-1.item img {
width: 100%;
height: auto;
}
.hamilton {
grid-row: 2 / span 2;
grid-column: 1 / span 2;
}
.moana {
grid-row: 4 / span 1;
grid-column: 1 / span 1;
margin: 0;
}
.chump {
grid-row: 5 / span 1;
grid-column: 2 / span 1;
}
.ith {
grid-row: 5 / span 1;
grid-column: 1 / span 1;
margin: 0;
}
.bringiton {
grid-row: 6 / span 1;
grid-column: 2 / span 1;
margin: 0;
}
.trophy {
margin: 1.5em 0 .5em;
}
.emmy {
grid-row: 2 / span 1;
}
.grammy {
grid-column: 1 / span 2;
grid-row: 3 / span 1;
}
.oscar {
grid-column: 1 / span 2;
grid-row: 4 / span 1;
margin: 0;
.coming-soon {
margin: -.5em 0 .5em;
}
}
.tony {
grid-column: 1 / span 2;
grid-row: 5 / span 1;
}
.book {
grid-row: 2 / span 4;
}
.book-info {
grid-column: 1 / span 2;
grid-row: 6 / span 1;
margin-left: 0;
margin-top: 3em;
}
.book img {
width: auto;
height: 200px;
}
}
@media screen and (max-width: 600px) {
label {
left: 0;
}
.profile-content {
padding: 3em 1em;
}
}
Also see: Tab Triggers