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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.
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.
If the stylesheet 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 CSS 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.
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.
html
body
// Demo stuff
main
h1
a(href='http://ettrics.com/') Ettrics
p
| A Material Design inspired expanding overlay for showcasing a variety of content.
p
a(href='https://twitter.com/ettrics/', target='_blank')
i.fa.fa-twitter
img.plate(src='https://s3-us-west-2.amazonaws.com/s.cdpn.io/45226/plate.svg', alt='')
// Component starts here
ul.blocks-names
li.blocks__name Eggs
li.blocks__name Bacon
li.blocks__name Toast
li.blocks__name Donuts
li.blocks__name Coffee
ul.blocks
li#1.blocks__block
li#2.blocks__block
li#3.blocks__block
li#4.blocks__block
li#5.blocks__block
ul.blocks-content
li.blocks-content__content
.content__close
h2 Eggs
p
| Lorem ipsum dolor sit amet, consectetur adipisicing elit. Vitae modi esse, totam sequi non quae, rerum facilis nesciunt iusto praesentium officiis assumenda dignissimos. Saepe, facere incidunt. Laudantium quisquam asperiores sint.
i.blocks__content-close.fa.fa-close
li.blocks-content__content
h2 Bacon
p
| Lorem ipsum dolor sit amet, consectetur adipisicing elit. Deleniti ducimus voluptate velit quae cumque neque minima harum libero eligendi alias laboriosam ad, consequuntur error atque incidunt assumenda sapiente! Architecto, excepturi?
i.blocks__content-close.fa.fa-close
li.blocks-content__content
h2 Toast
p
| Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sint eligendi quis accusantium recusandae iusto sed, magni iure magnam, architecto quisquam pariatur minus, rem alias. Eum voluptatem maiores quae reiciendis cupiditate.
i.blocks__content-close.fa.fa-close
li.blocks-content__content
h2 Donuts
p
| Lorem ipsum dolor sit amet, consectetur adipisicing elit. Delectus officiis voluptates et, atque animi quae hic dolorem neque magnam reprehenderit sint dolor omnis modi mollitia labore quidem aspernatur ab architecto.
i.blocks__content-close.fa.fa-close
li.blocks-content__content
h2 Coffee
p
| Lorem ipsum dolor sit amet, consectetur adipisicing elit. Delectus officiis voluptates et, atque animi quae hic dolorem neque magnam reprehenderit sint dolor omnis modi mollitia labore quidem aspernatur ab architecto.
i.blocks__content-close.fa.fa-close
$color1 = #f4d35d
$color2 = #db5b4a
$color3 = #e2bb7f
$color4 = #f67b7d
$color5 = #a1775a
*
box-sizing: border-box
body
font-family: 'Open Sans'
font-weight: 400
text-align: center
.blocks
position: fixed
bottom: 0
z-index: 1
list-style-type: none
display: flex
width: 100%
margin: 0
padding: 0
&__block
will-change: transform
position: relative
height: 20vh
flex: 1
transition: all 0.7s cubic-bezier(0.23, 1, 0.32, 1)
&:nth-child(1)
background: $color1
transform-origin: 0% 100%
&:nth-child(2)
background: $color2
transform-origin: 25% 100%
&:nth-child(3)
background: $color3
transform-origin: 50% 100%
&:nth-child(4)
background: $color4
transform-origin: 75% 100%
&:nth-child(5)
background: $color5
transform-origin: 100% 100%
&.active
z-index: 2
.blocks-content
list-style-type: none
margin: 0
padding: 0
position: absolute
bottom: 0
left: 0
height: 100vh
width: 100%
&__content
will-change: transform, opacity
display: flex
align-items: center
justify-content: center
text-align: center
flex-direction: column
position: fixed
width: 100%
z-index: 3
top: 0
left: 0
height: 100vh
padding: 10vw
font-size: 20px
opacity: 0
visibility: hidden
text-align: center
transform: scale(0.9)
transition: all .3s .2s ease-out
&.active
opacity: 1
transform: scale(1)
visibility: visible
.blocks__content-close
position: absolute
right: 2vw
top: 2vh
font-size: 30px
cursor: pointer
transition: all .2s ease-out
&:hover
transform: scale(1.1)
p
font-size: 16px
line-height: 2
max-width: 800px
h2
padding: 15px 30px
font-weight: 300
letter-spacing: 6px
box-shadow: inset 0 0 0 3px black
.blocks-names
position: fixed
bottom: 0
left: 0
z-index: 2
width: 100%
list-style-type: none
margin: 0
padding: 0
display: flex
font-size: 18px
letter-spacing: 4px
cursor: pointer
transition: all .15s ease-out
.blocks__name
flex: 1
height: 20vh
display: flex
align-items: center
justify-content: center
/* Demo */
main
position: relative
z-index: 1
padding: 3vh 5vw
height: 80vh
display: flex
flex-flow: column wrap
justify-content: center
background: rgba(#edc982, 0.85)
h1
margin: 0
font-weight: 300
color: #38C5B9
a
font-size: 48px
p
font-weight: 300
font-size: 16px
max-width: 340px
margin: 7px auto
a
text-decoration: none
color: #38C5B9
font-size: 30px
.plate
position: absolute
top: 50%
left: 50%
max-width: 380px
width: 100%
transform: translate(-50%, -50%)
z-index: -1
block = $('.blocks__block')
bname = $('.blocks__name')
content = $('.blocks-content__content')
closeBtn = $('.blocks__content-close')
wHeight = $(window).outerHeight()
wWidth = $(window).outerWidth()
bHeight = block.outerHeight()
bWidth = block.outerWidth()
xVal = Math.round(wWidth / bWidth) + 0.03
yVal = wHeight / bHeight + 0.03
expand = ->
num = $(this).index()
aBlock = block.eq(num)
if !aBlock.hasClass('active')
bname.css 'opacity', '0'
aBlock.css
'transform': 'scale(' + xVal + ',' + yVal + ')'
'-webkit-transform': 'scale(' + xVal + ',' + yVal + ')'
aBlock.addClass 'active'
openContent num
return
openContent = (num) ->
content.css
'transition': 'all 0.3s 0.4s ease-out'
'-webkit-transition': 'all 0.3s 0.4s ease-out'
aContent = content.eq(num)
aContent.addClass 'active'
return
closeContent = ->
bname.css 'opacity', '1'
content.css
'transition': 'all 0.1s 0 ease-out'
'-webkit-transition': 'all 0.1s 0 ease-out'
block.css
'transform': 'scale(1)'
'-webkit-transform': 'scale(1)'
block.removeClass 'active'
content.removeClass 'active'
return
updateValues = ->
`var yVal`
`var xVal`
`var bWidth`
`var bHeight`
`var wWidth`
`var wHeight`
if block.hasClass('active')
aBlock = $('.blocks__block.active')
wHeight = $(window).height()
wWidth = $(window).width()
bHeight = block.height()
bWidth = block.width()
xVal = Math.round(wWidth / bWidth) + 0.03
yVal = wHeight / bHeight + 0.03
aBlock.css
'transform': 'scale(' + xVal + ',' + yVal + ')'
'-webkit-transform': 'scale(' + xVal + ',' + yVal + ')'
return
$(window).on 'resize', updateValues
bname.on 'click', expand
closeBtn.on 'click', closeContent
Also see: Tab Triggers