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 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.
doctype html
head
meta(charset="utf-8")
link(rel="stylesheet", href="/styl.css", media="screen", charset="utf-8")
script(type="text/javascript", src="//code.jquery.com/jquery-1.12.0.min.js")
script(type="text/javascript", src="script.js")
title Color picker
body
.shadowBox
.container
.blueSub
.redSub
.greenSub
.purpleSub
.blue
.colorName Blue
.hex #00A8FF
.rgb rgb(0, 168, 255)
.red
.colorName Red
.hex #FF605F
.rgb rgb(255, 96, 95)
.green
.colorName Green
.hex #96D100
.rgb rgb(150, 209, 0)
.purple
.colorName Purple
.hex #D066FA
.rgb rgb(208, 102, 250)
@import url(https://fonts.googleapis.com/css?family=Lato:300)
$blue = rgba(0, 168, 255, 1)
$blue10 = rgba(0, 168, 255, .1)
$blue20 = rgba(0, 168, 255, .2)
$blueDark = rgba(0, 94, 142, 1)
$red = rgba(255, 96, 95, 1)
$red10 = rgba(255, 96, 95, .1)
$red20 = rgba(255, 96, 95, .2)
$green = rgba(150, 209, 0, 1)
$green10 = rgba(150, 209, 0, .1)
$green20 = rgba(150, 209, 0, .2)
$purple = rgba(208, 102, 250, 1)
$purple10 = rgba(208, 102, 250, .1)
$purple20 = rgba(208, 102, 250, .2)
$containerColor = #fff
$containerWidth = 416px
$containerHeight = 128px
$containerBorderRadius = 16px
// $containerShadow = 0px 16px 32px rgba(0,0,0,.05)
*
transition all .7s ease
box-sizing border-box
body
background $blue10
display flex
justify-content center
align-items center
width 100vw
height 100vh
font-family 'Lato', sans-serif
font-weight 300
overflow hidden
.shadowBox
position absolute
background $blueDark
width 376px
height 96px
z-index 0
border-radius 16px
margin-top 32px
-webkit-filter blur(20px)
opacity .2
top 50%
left 50%
margin-left -188px
margin-top -16px
z-index -1
.container
background $containerColor
width $containerWidth
height $containerHeight
border-radius $containerBorderRadius
box-shadow $containerShadow
color white
font-size 16px
z-index 1
overflow hidden
.blueSub, .redSub, .greenSub, .purpleSub
position absolute
width 80px
height 80px
border-radius 12px
margin-top 24px
.blueSub
background $blue20
margin-left 24px
margin-top 24px
.redSub
background $red20
margin-left 120px
opacity 0
.greenSub
background $green20
margin-left 216px
opacity 0
.purpleSub
background $purple20
margin-left 312px
opacity 0
.blue, .red, .green, .purple
width 64px
height 64px
border-radius 8px
z-index 2
position absolute
overflow hidden
.blue
background $blue
margin-left 32px
margin-top 32px
&:hover
cursor pointer
.red
background $red
margin-top 32px
margin-left 128px
&:hover
cursor pointer
.green
background $green
margin-top 32px
margin-left 224px
&:hover
cursor pointer
.purple
background $purple
margin-top 32px
margin-left 320px
&:hover
cursor pointer
.colorName, .hex, .rgb
opacity 0
position absolute
.colorName
font-size 26px
margin-top 9px
left 16px
.hex
margin-top 12px
right 16px
.rgb
margin-top 80px
right 16px
$(document).ready ->
count = 0
# Colors
blue10 = "rgba(0, 168, 255, .1)"
red10 = "rgba(255, 96, 95, .1)"
green10 = "rgba(150, 209, 0, .1)"
purple10 = "rgba(208, 102, 250, .1)"
blueDark = "rgba(0, 94, 142, 1)"
redDark = "rgba(155, 3, 0, 1)"
greenDark = "rgba(74, 103, 0, 1)"
purpleDark = "rgba(110, 49, 134, 1)"
$(".blue").on "mouseover", ->
resetAllSubs()
$(".blueSub").css("opacity":"1", "transition-delay": "0s")
$("body").css("background":blue10, "transition-delay": "0s")
$(".shadowBox").css("background":blueDark, "transition-delay": "0s")
$(".red").on "mouseover", ->
resetAllSubs()
$(".redSub").css("opacity":"1", "transition-delay": "0s")
$("body").css("background":red10, "transition-delay": "0s")
$(".shadowBox").css("background":redDark, "transition-delay": "0s")
$(".green").on "mouseover", ->
resetAllSubs()
$(".greenSub").css("opacity":"1", "transition-delay": "0s")
$("body").css("background":green10, "transition-delay": "0s")
$(".shadowBox").css("background":greenDark, "transition-delay": "0s")
$(".purple").on "mouseover", ->
resetAllSubs()
$(".purpleSub").css("opacity":"1", "transition-delay": "0s")
$("body").css("background":purple10, "transition-delay": "0s")
$(".shadowBox").css("background":purpleDark, "transition-delay": "0s")
$(".blue").on "click", ->
if count > 1
count = 0
transformation("blue")
count += 1
$(".red").on "click", ->
if count > 1
count = 0
transformation("red")
count += 1
$(".green").on "click", ->
if count > 1
count = 0
transformation("green")
count += 1
$(".purple").on "click", ->
if count > 1
count = 0
transformation("purple")
count += 1
resetAllSubs = () ->
$(".blueSub").css("opacity":"0", "transition-delay": "0s")
$(".redSub").css("opacity":"0", "transition-delay": "0s")
$(".greenSub").css("opacity":"0", "transition-delay": "0s")
$(".purpleSub").css("opacity":"0", "transition-delay": "0s")
transformation = (layer) ->
if count is 0
switch layer
when "blue"
#Divs
$(".blue").css("z-index": "3", "width":"400px", "height":"112px", "margin-top": "8px", "margin-left": "8px", "transition-delay": ".5s")
$(".blueSub").css("opacity": "0", "transform":"scale(0)", "transition-delay": ".05s")
$(".red").css("opacity": "0", "transform":"scale(0)", "transition-delay": ".1s")
$(".redSub").css("opacity": "0", "transform":"scale(0)", "transition-delay": ".075s")
$(".green").css("opacity": "0", "transform":"scale(0)", "transition-delay": ".15s")
$(".greenSub").css("opacity": "0", "transform":"scale(0)", "transition-delay": ".125s")
$(".purple").css("opacity": "0", "transform":"scale(0)", "transition-delay": ".2s")
$(".purpleSub").css("opacity": "0", "transform":"scale(0)", "transition-delay": ".175s")
#Texts
$(".blue .colorName").css("opacity": "1", "transition-delay": ".75s")
$(".blue .hex").css("opacity": "1", "transition-delay": ".8s")
$(".blue .rgb").css("opacity": "1", "transition-delay": ".85s")
when "red"
#Divs
$(".red").css("z-index": "3", "width":"400px", "height":"112px", "margin-top": "8px", "margin-left": "8px", "transition-delay": ".5s")
$(".redSub").css("opacity": "0", "transform":"scale(0)", "transition-delay": ".05s")
$(".blue").css("opacity": "0", "transform":"scale(0)", "transition-delay": ".1s")
$(".blueSub").css("opacity": "0", "transform":"scale(0)", "transition-delay": ".075s")
$(".green").css("opacity": "0", "transform":"scale(0)", "transition-delay": ".15s")
$(".greenSub").css("opacity": "0", "transform":"scale(0)", "transition-delay": ".125s")
$(".purple").css("opacity": "0", "transform":"scale(0)", "transition-delay": ".2s")
$(".purpleSub").css("opacity": "0", "transform":"scale(0)", "transition-delay": ".175s")
#Texts
$(".red .colorName").css("opacity": "1", "transition-delay": ".75s")
$(".red .hex").css("opacity": "1", "transition-delay": ".8s")
$(".red .rgb").css("opacity": "1", "transition-delay": ".85s")
when "green"
#Divs
$(".green").css("z-index": "3", "width":"400px", "height":"112px", "margin-top": "8px", "margin-left": "8px", "transition-delay": ".5s")
$(".greenSub").css("opacity": "0", "transform":"scale(0)", "transition-delay": ".05s")
$(".blue").css("opacity": "0", "transform":"scale(0)", "transition-delay": ".1s")
$(".blueSub").css("opacity": "0", "transform":"scale(0)", "transition-delay": ".075s")
$(".red").css("opacity": "0", "transform":"scale(0)", "transition-delay": ".15s")
$(".redSub").css("opacity": "0", "transform":"scale(0)", "transition-delay": ".125s")
$(".purple").css("opacity": "0", "transform":"scale(0)", "transition-delay": ".2s")
$(".purpleSub").css("opacity": "0", "transform":"scale(0)", "transition-delay": ".175s")
#Texts
$(".green .colorName").css("opacity": "1", "transition-delay": ".75s")
$(".green .hex").css("opacity": "1", "transition-delay": ".8s")
$(".green .rgb").css("opacity": "1", "transition-delay": ".85s")
when "purple"
#Divs
$(".purple").css("z-index": "3", "width":"400px", "height":"112px", "margin-top": "8px", "margin-left": "8px", "transition-delay": ".5s")
$(".purpleSub").css("opacity": "0", "transform":"scale(0)", "transition-delay": ".05s")
$(".blue").css("opacity": "0", "transform":"scale(0)", "transition-delay": ".1s")
$(".blueSub").css("opacity": "0", "transform":"scale(0)", "transition-delay": ".075s")
$(".red").css("opacity": "0", "transform":"scale(0)", "transition-delay": ".15s")
$(".redSub").css("opacity": "0", "transform":"scale(0)", "transition-delay": ".125s")
$(".green").css("opacity": "0", "transform":"scale(0)", "transition-delay": ".2s")
$(".greenSub").css("opacity": "0", "transform":"scale(0)", "transition-delay": ".175s")
#Texts
$(".purple .colorName").css("opacity": "1", "transition-delay": ".75s")
$(".purple .hex").css("opacity": "1", "transition-delay": ".8s")
$(".purple .rgb").css("opacity": "1", "transition-delay": ".85s")
if count is 1
switch layer
when "blue"
#Divs
$(".blue").css("z-index": "2", "width":"64px", "height":"64px", "margin-top": "32px", "margin-left": "32px", "transition-delay": ".5s")
$(".blueSub").css("opacity": "1", "transform":"scale(1)", "transition-delay": ".8s")
$(".red").css("opacity": "1", "transform":"scale(1)", "transition-delay": ".9s")
$(".redSub").css("opacity": "0", "transform":"scale(1)", "transition-delay": ".875s")
$(".green").css("opacity": "1", "transform":"scale(1)", "transition-delay": ".95s")
$(".greenSub").css("opacity": "0", "transform":"scale(1)", "transition-delay": ".925s")
$(".purple").css("opacity": "1", "transform":"scale(1)", "transition-delay": "1s")
$(".purpleSub").css("opacity": "0", "transform":"scale(1)", "transition-delay": ".975s")
#Texts
$(".blue .colorName").css("opacity": "0", "transition-delay": ".15s")
$(".blue .hex").css("opacity": "0", "transition-delay": ".1s")
$(".blue .rgb").css("opacity": "0", "transition-delay": "0s")
when "red"
#Divs
$(".red").css("z-index": "2", "width":"64px", "height":"64px", "margin-top": "32px", "margin-left": "128px", "transition-delay": ".5s")
$(".redSub").css("opacity": "1", "transform":"scale(1)", "transition-delay": ".8s")
$(".blue").css("opacity": "1", "transform":"scale(1)", "transition-delay": ".9s")
$(".blueSub").css("opacity": "0", "transform":"scale(1)", "transition-delay": ".875s")
$(".green").css("opacity": "1", "transform":"scale(1)", "transition-delay": ".95s")
$(".greenSub").css("opacity": "0", "transform":"scale(1)", "transition-delay": ".925s")
$(".purple").css("opacity": "1", "transform":"scale(1)", "transition-delay": "1s")
$(".purpleSub").css("opacity": "0", "transform":"scale(1)", "transition-delay": ".975s")
#Texts
$(".red .colorName").css("opacity": "0", "transition-delay": ".15s")
$(".red .hex").css("opacity": "0", "transition-delay": ".1s")
$(".red .rgb").css("opacity": "0", "transition-delay": "0s")
when "green"
#Divs
$(".green").css("z-index": "2", "width":"64px", "height":"64px", "margin-top": "32px", "margin-left": "224px", "transition-delay": ".5s")
$(".greenSub").css("opacity": "1", "transform":"scale(1)", "transition-delay": ".8s")
$(".blue").css("opacity": "1", "transform":"scale(1)", "transition-delay": ".9s")
$(".blueSub").css("opacity": "0", "transform":"scale(1)", "transition-delay": ".875s")
$(".red").css("opacity": "1", "transform":"scale(1)", "transition-delay": ".95s")
$(".redSub").css("opacity": "0", "transform":"scale(1)", "transition-delay": ".925s")
$(".purple").css("opacity": "1", "transform":"scale(1)", "transition-delay": "1s")
$(".purpleSub").css("opacity": "0", "transform":"scale(1)", "transition-delay": ".975s")
#Texts
$(".green .colorName").css("opacity": "0", "transition-delay": ".15s")
$(".green .hex").css("opacity": "0", "transition-delay": ".1s")
$(".green .rgb").css("opacity": "0", "transition-delay": "0s")
when "purple"
#Divs
$(".purple").css("z-index": "2", "width":"64px", "height":"64px", "margin-top": "32px", "margin-left": "320px", "transition-delay": ".5s")
$(".purpleSub").css("opacity": "1", "transform":"scale(1)", "transition-delay": ".8s")
$(".blue").css("opacity": "1", "transform":"scale(1)", "transition-delay": ".9s")
$(".blueSub").css("opacity": "0", "transform":"scale(1)", "transition-delay": ".875s")
$(".red").css("opacity": "1", "transform":"scale(1)", "transition-delay": ".95s")
$(".redSub").css("opacity": "0", "transform":"scale(1)", "transition-delay": ".925s")
$(".green").css("opacity": "1", "transform":"scale(1)", "transition-delay": "1s")
$(".greenSub").css("opacity": "0", "transform":"scale(1)", "transition-delay": ".975s")
#Texts
$(".purple .colorName").css("opacity": "0", "transition-delay": ".15s")
$(".purple .hex").css("opacity": "0", "transition-delay": ".1s")
$(".purple .rgb").css("opacity": "0", "transition-delay": "0s")
Also see: Tab Triggers