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.
-# NEW VERSION: https://codepen.io/mican/pen/RyjZgm
%article.gallery
- [1081, 1014, 267, 266, 634, 923, 682, 173, 943].each do |i|
- height = 200 * [5,6,7,8].shuffle.first.to_i
- width = 200 * [5,6,7,8].shuffle.first.to_i
%a.gallery-link{:href => "https://unsplash.it/#{width}/#{height}?image=#{i}"}
%figure.gallery-image
%img{src: "https://unsplash.it/#{width}/#{height}?image=#{i}", width: width, height: height}
%figcaption Photo caption
%footer#footer{role: 'contentinfo'}
.container
%a.logo{href: 'https://codepen.io/collection/XRoxGR', rel: 'home'} Calibration theme
%a.copy{href: 'https://mobilemarkup.com', target: '_blank'} © mobileMarkup.com
%gallery-image-caption
position: absolute
top: 50%
left: 50%
transform: translate(-50%,-50%)
font-size: 14px
color: rgba(white,0)
padding: 1em
transition: all .2s ease
font-weight: 600
max-width: calc(100% - 9em)
line-height: 1.25
text-align: center
box-sizing: border-box
&:before, &:after
content: ''
position: absolute
background: rgba(black,.2)
width: 100%
height: 100%
padding: 1em
transition: all .3s ease-in-out
opacity: 0
z-index: -1
&:before, &:after
right: 100%
bottom: 100%
&:after
left: 100%
top: 100%
%gallery-image-caption-visible
color: rgba(white,1)
text-shadow: 0 0 1px rgba(black,.2)
transition: all .2s ease .3s
&:before, &:after
opacity: 1
&:before
right: -1.5em
bottom: -1.5em
&:after
left: -1.5em
top: -1.5em
html
-moz-osx-font-smoothing: grayscale
-webkit-font-smoothing: antialiased
text-rendering: optimizelegibility
body
font-family: 'Montserrat', sans-serif
.gallery
column-gap: 0
@media (min-width: 480px)
column-count: 2
@media (min-width: 1260px)
column-count: 3
.gallery-image
position: relative
margin: 0
padding: 0
&:before, &:after
content: ''
position: absolute
top: 0
left: 0
right: 0
bottom: 0
border: 16px solid rgba(black,.1)
transition: all .2s
will-change: border
&:after
border-width: 0
img
display: block
max-width: 100%
height: auto
html:not(.touch) &
overflow: hidden
figcaption
@extend %gallery-image-caption
&:hover
&:before
border-width: 16px
&:after
border-width: 32px
figcaption
@extend %gallery-image-caption-visible
.touch &
figcaption
@extend %gallery-image-caption
@extend %gallery-image-caption-visible
top: auto
bottom: 2em
.mfp-with-zoom
.mfp-container, &.mfp-bg
opacity: 0
backface-visibility: hidden
transition: all 0.3s ease-out
&.mfp-bg
background-color: rgba(black,.9)
&.mfp-ready
.mfp-container
opacity: 1
&.mfp-bg
opacity: 1
&.mfp-removing
.mfp-container, &.mfp-bg
opacity: 0
// .mfp-no-margins
img.mfp-img
padding: 0
.mfp-figure:after
top: 0
bottom: 0
.mfp-container
padding: 0
.mfp-content
overflow: hidden
.mfp-bottom-bar
top: auto
bottom: 0
margin-top: 0
.mfp-title
@extend %gallery-image-caption
top: auto
bottom: 2em
&.mfp-ready .mfp-title
@extend %gallery-image-caption-visible
.mfp-arrow
opacity: 1
margin-top: 0!important
width: 20%
height: 30%
// background: rgba(black,.2)!important
transform: translateY(-50%)
&:hover, &:focus
&:before, &:after
margin: 0
border: none
width: 2rem
height: 2rem
transform: rotate(-45deg) translate(-50%,-100%)
opacity: 1
top: 50%
left: 50%
transition: all .15s
&:active
transform: translateY(-50%) scale(.95)
.mfp-arrow-left
left: 0
&:before, &:after
border-top: 2px solid white
border-left: 2px solid white
&:before
&:after
margin-left: 2rem
&:hover, &:active
&:before
margin-left: 2rem
&:after
margin-left: 0
.mfp-arrow-right
right: 0
&:before, &:after
border-right: 2px solid white
border-bottom: 2px solid white
&:before
&:after
margin-left: 2rem
&:hover
&:before
margin-left: 2rem
&:after
margin-left: 0
button.mfp-close
opacity: 1
margin-top: 0!important
width: 20%
height: 30%
font: 0/0 serif
text-shadow: none
color: transparent
&:hover, &:focus
&:before, &:after
content: ''
position: absolute
top: 50%
left: 50%
margin: 0
border: none
width: 2rem
height: 2rem
opacity: 1
transition: all .15s
transform-origin: 0 0
border-top: 2px solid white
border-left: 2px solid white
&:before
transform: rotate(-45deg)
&:after
transform: rotate(135deg)
&:hover
&:before
transform: rotate(135deg)
&:after
transform: rotate(315deg)
&:active
transform: scale(.95)
a
text-decoration: none
color: inherit
[id=footer]
margin-top: 10vh
padding: 10vh 0
text-align: center
.container
position: relative
&:before, &:after
content: ''
position: absolute
bottom: 100%
left: 20px
z-index: 10
border-top: 2px solid
width: 10%
margin-bottom: 10vh
&:after
left: auto
right: 20px
*
display: block
+ *
margin-top: 5vh
.logo
font-weight: 600
font-size: 1.5em
.copy
text-transform: uppercase
font-size: .75em
font-weight: 600
$('.gallery-link').magnificPopup
type: 'image'
closeOnContentClick: true
closeBtnInside: false
mainClass: 'mfp-with-zoom mfp-img-mobile'
image:
verticalFit: true
titleSrc: (item) ->
item.el.find('figcaption').text() || item.el.attr('title')
zoom:
enabled: true
# duration: 300
gallery:
enabled: true
navigateByImgClick: false
tCounter: ''
disableOn: ->
$(window).width() > 640
Also see: Tab Triggers