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.
- const fields = {
- physics: "atom",
- chemistry: "flask",
- biology: "leaf",
- computers: "robot",
-}
- const scientists = {
- einstein: {
- name: "Albert Einstein",
- image: "https://www.nationalgeographic.com.es/medio/2018/07/26/albert-einstein__800x800.jpg",
- field: "physics",
- quote: "Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world",
- dates: {
- born: "14-03-1879",
- dead: "18-04-1955"
- },
- signature: "https://upload.wikimedia.org/wikipedia/commons/thumb/d/d7/Albert_Einstein_signature_1934.svg/1920px-Albert_Einstein_signature_1934.svg.png",
- bio: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec condimentum odio vel elit volutpat, pretium consectetur orci malesuada. Ut maximus tempus interdum. Aliquam in nunc ante. Pellentesque et sapien varius nulla tincidunt congue. Proin a semper turpis. Aliquam fringilla, libero a pellentesque sagittis, justo felis rutrum augue, at ullamcorper eros dolor feugiat odio. Etiam facilisis fermentum nunc in ornare. Etiam vitae odio ligula. Proin bibendum nisl ipsum, in tincidunt augue interdum et. Donec luctus nibh vel magna facilisis, ut rutrum erat lobortis."
- },
- curie: {
- name: "Marie Curie",
- image: "https://www.librerantes.com/wp-content/uploads/2017/04/marie-curie.jpg",
- field: "chemistry",
- quote: "Be less curious about people and more curious about ideas",
- dates: {
- born: "7-11-1867",
- dead: "4-07-1934"
- },
- signature: "https://upload.wikimedia.org/wikipedia/commons/thumb/c/c2/Marie_Curie_Sk%C5%82odowska_Signature_Polish.svg/1920px-Marie_Curie_Sk%C5%82odowska_Signature_Polish.svg.png",
- bio: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec condimentum odio vel elit volutpat, pretium consectetur orci malesuada. Ut maximus tempus interdum. Aliquam in nunc ante. Pellentesque et sapien varius nulla tincidunt congue. Proin a semper turpis. Aliquam fringilla, libero a pellentesque sagittis, justo felis rutrum augue, at ullamcorper eros dolor feugiat odio. Etiam facilisis fermentum nunc in ornare. Etiam vitae odio ligula. Proin bibendum nisl ipsum, in tincidunt augue interdum et. Donec luctus nibh vel magna facilisis, ut rutrum erat lobortis."
- },
- darwin: {
- name: "Charles Darwin",
- image: "https://media.mnn.com/assets/images/2016/02/charles-darwin-wicker-chair-1880.jpg.653x0_q80_crop-smart.jpg",
- field: "biology",
- quote: "A man who dares to waste one hour of time has not discovered the value of life",
- dates: {
- born: "12-02-1809",
- dead: "19-04-1882"
- },
- signature: "https://upload.wikimedia.org/wikipedia/commons/thumb/b/b1/Charles_Darwin_Signature.svg/1920px-Charles_Darwin_Signature.svg.png",
- bio: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec condimentum odio vel elit volutpat, pretium consectetur orci malesuada. Ut maximus tempus interdum. Aliquam in nunc ante. Pellentesque et sapien varius nulla tincidunt congue. Proin a semper turpis. Aliquam fringilla, libero a pellentesque sagittis, justo felis rutrum augue, at ullamcorper eros dolor feugiat odio. Etiam facilisis fermentum nunc in ornare. Etiam vitae odio ligula. Proin bibendum nisl ipsum, in tincidunt augue interdum et. Donec luctus nibh vel magna facilisis, ut rutrum erat lobortis."
- },
- turing: {
- name: "Alan Turing",
- image: "https://tr2.cbsistatic.com/hub/i/2014/11/04/dceb5c17-b8c4-4f82-9a4a-42750f3854fe/turing5.jpg",
- field: "computers",
- quote: "Those who can imagine anything, can create the impossible",
- dates: {
- born: "23-06-1912",
- dead: "7-06-1954"
- },
- signature: "https://upload.wikimedia.org/wikipedia/commons/thumb/8/83/Alan_Turing_signature.svg/1920px-Alan_Turing_signature.svg.png",
- bio: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec condimentum odio vel elit volutpat, pretium consectetur orci malesuada. Ut maximus tempus interdum. Aliquam in nunc ante. Pellentesque et sapien varius nulla tincidunt congue. Proin a semper turpis. Aliquam fringilla, libero a pellentesque sagittis, justo felis rutrum augue, at ullamcorper eros dolor feugiat odio. Etiam facilisis fermentum nunc in ornare. Etiam vitae odio ligula. Proin bibendum nisl ipsum, in tincidunt augue interdum et. Donec luctus nibh vel magna facilisis, ut rutrum erat lobortis."
- }
- }
// --- MIXINS ---
mixin createPresentation(biographyData, id)
.card__presentation
.card__presentation__info
h1= biographyData.name
blockquote= biographyData.quote
button.card__button(onclick=`showInformation('${id}')`) show more
mixin createInformation(biographyData, id)
.card__info
.card__info__main-info
.main-info__field
+getIcon(biographyData.field)
span= biographyData.field
h3= biographyData.name
.main-info__date
time= biographyData.dates.born
time= biographyData.dates.dead
.card__info__biography= biographyData.bio
.card__info__signature
img(src=biographyData.signature, alt=biographyData.name + "signature")
.card__info__control
button.card__button(onclick=`showPresentation('${id}')`) show less
mixin createCard(biographyData, id)
- let bg = {'background-image': "url(" + biographyData.image + ")"}
.card(style=bg)
.wrapper.wrapper__presentation(id=`${id}-presentation`)
+createPresentation(biographyData, id)
.wrapper.wrapper__info(id=`${id}-info`)
+createInformation(biographyData, id)
mixin getIcon(field)
i(class="fas fa-" + fields[field])
// -- CREATION --
.title
h1 science hall of fame
.title__author
i(class="fa fa-code").
span by
a(href="https://github.com/CristianAbrante") CristianAbrante
.container
each scientist, id in scientists
-console.log('hola')
+createCard(scientist, id)
@import url('https://fonts.googleapis.com/css?family=Open+Sans:300,400,700|Playfair+Display')
$cards-width: 400px
*
margin: 0
body
background: #536976
background: linear-gradient(#292E49, #536976)
.title
display: flex
flex-direction: column
justify-content: center
margin: 20px
border-bottom: 1px solid white
h1
color: white
font-family: 'Playfair Display', serif
text-transform: capitalize
font-weight: 300
font-size: 4rem
text-align: center
text-shadow: 0px 0px 20px black
margin: 5px 20px
.title__author
font-family: 'Open Sans', sans-serif
display: flex
justify-content: center
align-items: center
color: white
margin-bottom: 10px
font-size: 1.2rem
*
margin: 4px
a
text-decoration: none
font-weight: bold
color: white
.container
margin: auto
padding: 10px
display: grid
grid-template-columns: repeat(auto-fit, minmax($cards-width, 1fr))
grid-gap: 20px
width: 60%
.wrapper
height: 100%
.card
background-size: cover
background-repeat: no-repeat
font-family: 'Open Sans', sans-serif
box-shadow: 0px 0px 50px
border-radius: 5px
height: 600px
display: flex
flex-direction: column
justify-content: flex-end
&:hover
.card__presentation__info
h1
border-bottom: 1px solid white
blockquote
display: block
animation: quoteAnimation 0.5s ease-in
button
display: inline
animation: buttonAnimation 0.5s ease-in
// --------------------
// PRESENTATION STYLES
// --------------------
.wrapper__presentation
height: 100%
.card__presentation
color: white
height: 100%
display: flex
flex-direction: column
justify-content: flex-end
.card__presentation__info
background: linear-gradient(rgba(0,0,0,0), black)
padding: 20px 20px 40px
border-radius: 5px
display: flex
flex-direction: column
h1
text-transform: uppercase
font-size: 5rem
line-height: 4.5rem
blockquote
display: none
font-style: italic
font-size: 1.3rem
font-family: 'Open Sans', cursive
margin: 15px
text-align: center
button
display: none
align-self: center
// --------------------
// INFORMATION STYLES
// --------------------
.wrapper__info
display: none
.card__info
background: #000000
background: -webkit-linear-gradient(#434343, #000000)
background: linear-gradient(#434343, #000000)
opacity: 0.8
color: white
display: flex
flex-direction: column
justify-content: space-between
align-items: center
padding: 20px 20px 40px
height: 90%
border-radius: 5px
animation: infoAnimation 0.7s ease-in
.card__info__main-info
.main-info__field
display: flex
justify-content: center
align-items: center
font-size: 1.3rem
text-transform: uppercase
*
margin: 3px
h3
font-size: 3rem
text-transform: uppercase
border-bottom: 1px solid white
width: 100%
text-align: center
animation: textAnimation 0.2s ease-in
.main-info__date
display: flex
justify-content: space-around
font-size: 1.5rem
text-transform: uppercase
.card__info__biography
padding: 20px
margin: 10px
max-width: 600px
align-self: center
overflow: auto
.card__info__signature
margin: 20px
img
color: white
display: block
margin: auto
width: 80%
max-width: 600px
filter: brightness(0) invert(1)
.card__button
background: none
font-family: 'Open Sans', sans-serif
text-transform: uppercase
color: white
font-size: 1rem
border: 1px solid white
animation: buttonAnimation 1s ease-in
&:hover
background: white
color: black
&::after
content: "🡒"
// --------------------
// MEDIA QUERIES
// --------------------
@media only screen and (max-width : 640px)
.container
width: 95%
// --------------------
// ANIMATIONS
// --------------------
@keyframes quoteAnimation
0%
transform: translateY(10px)
opacity: 0
100%
transform: translateY(0px)
opacity: 1
@keyframes buttonAnimation
0%
opacity: 0
transform: scale3D(0.7,0.7,0.7)
100%
opacity: 1
transform: scale3D(1,1,1)
@keyframes textAnimation
0%
opacity: 0
100%
opacity: 1
@keyframes infoAnimation
0%
opacity: 0
transform: translateY(18px)
100%
opacity: 0.8
transform: translateY(0px)
function showPresentation(name) {
document.getElementById(name + '-info').style.display = 'none';
document.getElementById(name + '-presentation').style.display = 'block';
}
function showInformation(name) {
let info = document.getElementById(name + '-info');
document.getElementById(name + '-presentation').style.display = 'none';
info.style.display = 'block';
info.classList.remove("wrapper__info");
void element.offsetWidth;
info.classList.add("wrapper__info");
}
Also see: Tab Triggers