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.
// Download the Free scene from https://www.mockupcloud.com/free/art-craft-stationery-branding-mockup
.main-bg(style='background: linear-gradient(to bottom left, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0) 15%, rgba(0, 0, 0, 0.25) 65%, rgba(0, 0, 0, 0.4) 100%), url(https://i.ibb.co/xFVvGfd/bg.jpg) no-repeat center center fixed;')
// Document
#document.drag.document-cont.obj-cont
img.shadow.obj.document(src='https://i.ibb.co/F5VZPwk/document-ar-210-297-shadow.png')
img.no-shadow.obj.document(src='https://i.ibb.co/r7j25DK/document-ar-210-297.png')
// Ruler
#ruler.ruler-cont.obj-cont
img.shadow.obj.ruler(src='https://i.ibb.co/R4jwmvg/ruler-shadow.png')
img.no-shadow.obj.ruler(src='https://i.ibb.co/tMfdkrZ/ruler.png')
// Sharpener
#sharpener.sharpener-cont.obj-cont
img.shadow.obj.sharpener(src='https://i.ibb.co/0jCpxqX/sharpener-shadow.png')
img.no-shadow.obj.sharpener(src='https://i.ibb.co/GpQFr5S/sharpener.png')
// Pencil 1
#pencil-1.pencil-cont.obj-cont
img.shadow.obj.pencil(src='https://i.ibb.co/ySJx1Lm/pencil-shadow.png')
img.no-shadow.obj.pencil(src='https://i.ibb.co/JmF6cKf/pencil.png')
// Pencil 2
#pencil-2.pencil-cont.obj-cont
img.shadow.obj.pencil(src='https://i.ibb.co/ySJx1Lm/pencil-shadow.png')
img.no-shadow.obj.pencil(src='https://i.ibb.co/JmF6cKf/pencil.png')
// Clew
#clew.clew-cont.obj-cont
img.shadow.obj.clew(src='https://i.ibb.co/zSgm99f/clew-shadow.png')
img.no-shadow.obj.clew(src='https://i.ibb.co/sKQFBDf/clew.png')
// Clew Color
#clew-color.clew-color-cont.obj-cont
img.shadow.obj.clew-color(src='https://i.ibb.co/0jGwx9K/clew-color-shadow.png')
img.no-shadow.obj.clew-color(src='https://i.ibb.co/m8Qn0jS/clew-color.png')
// Brush
#brush.brush-cont.obj-cont
img.shadow.obj.brush(src='https://i.ibb.co/3d4FnLy/brush-shadow.png')
img.no-shadow.obj.brush(src='https://i.ibb.co/pP8VXPt/brush.png')
// Box
#box.box-cont.obj-cont
img.shadow.obj.box(src='https://i.ibb.co/kGH3dDj/box-shadow.png')
img.no-shadow.obj.box(src='https://i.ibb.co/CzcSWVG/box.png')
// Awl
#awl.awl-cont.obj-cont
img.shadow.obj.awl(src='https://i.ibb.co/jDjWSkD/awl-shadow.png')
img.no-shadow.obj.awl(src='https://i.ibb.co/3k82J1f/awl.png')
// Business Card 1
#business-card-1.business-card-cont.obj-cont
img.shadow.obj.business-card(src='https://i.ibb.co/ZTmVBkM/business-card-1-85-55-shadow.png')
img.no-shadow.obj.business-card(src='https://i.ibb.co/2KgxMXC/business-card-1-85-55.png')
// Business Card 2
#business-card-2.business-card-cont.obj-cont
img.shadow.obj.business-card(src='https://i.ibb.co/bL5CTJf/business-card-2-85-55-shadow.png')
img.no-shadow.obj.business-card(src='https://i.ibb.co/9VXCKBb/business-card-2-85-55.png')
// Envelope
#envelope.envelope-cont.obj-cont
img.shadow.obj.envelope(src='https://i.ibb.co/TqJRDDW/envelope-dl-110-220-shadow.png')
img.no-shadow.obj.envelope(src='https://i.ibb.co/rdrL5Mn/envelope-dl-110-220.png')
.main-bg
width: 100%
height: auto
display: block
min-height: 100%
-webkit-background-size: auto !important
-moz-background-size: auto !important
-o-background-size: auto !important
background-size: auto !important
width: 100%
height: auto
position: fixed
top: 0
left: 0
.obj-cont
position: relative
.obj
border: 3px solid transparent
.resizing
border: 3px solid transparentize(#000, 0.7)
z-index: 9
.shadow
mix-blend-mode: multiply
.no-shadow
.obj
position: absolute
.drag:hover
cursor: pointer
// Container and their positions
.document-cont
left: 31%
top: 9em
.ruler-cont
left: 40%
top: 40em
.sharpener-cont
left: 58%
top: 45em
#pencil-1
left: 42%
top: 37em
#pencil-2
top: 35em
left: 43%
.clew-cont
left: 37%
top: 0
.clew-color-cont
left: 48%
top: 5em
.brush-cont
left: 53%
top: 12em
.box-cont
left: 54%
top: 5em
.awl-cont
top: 8em
left: 27%
#business-card-1
top: 24em
left: 27%
#business-card-2
left: 34%
top: 29em
.envelope-cont
left: 54%
top: 21.5em
// The width of the objects
.document
width: 33%
.ruler
width: 20%
.sharpener
width: 4%
.clew
width: 12%
.awl
width: 12%
.clew-color
width: 8%
.pencil
width: 16%
.business-card
width: 9%
.brush
width: 13%
.box
width: 16%
.envelope
width: 20%
#mydiv
position: absolute
.ui-draggable:hover
cursor: pointer
.ui-draggable-dragging:active
cursor: move
# things = '#glass-box, #tin-box, #paper-holder, #candle, #clock, #clew-color, #brush'
# Make the DIV element draggable:
dragElement = (elmnt) ->
pos1 = 0
pos2 = 0
pos3 = 0
pos4 = 0
dragMouseDown = (e) ->
e = e or window.event
e.preventDefault()
# get the mouse cursor position at startup:
pos3 = e.clientX
pos4 = e.clientY
document.onmouseup = closeDragElement
# call a function whenever the cursor moves:
document.onmousemove = elementDrag
return
elementDrag = (e) ->
e = e or window.event
e.preventDefault()
# calculate the new cursor position:
pos1 = pos3 - (e.clientX)
pos2 = pos4 - (e.clientY)
pos3 = e.clientX
pos4 = e.clientY
# set the element's new position:
elmnt.style.top = elmnt.offsetTop - pos2 + 'px'
elmnt.style.left = elmnt.offsetLeft - pos1 + 'px'
return
closeDragElement = ->
# stop moving when mouse button is released:
document.onmouseup = null
document.onmousemove = null
return
if document.getElementById(elmnt.id + 'header')
# if present, the header is where you move the DIV from:
document.getElementById(elmnt.id + 'header').onmousedown = dragMouseDown
else
# otherwise, move the DIV from anywhere inside the DIV:
elmnt.onmousedown = dragMouseDown
return
dragElement document.getElementById('document')
dragElement document.getElementById('ruler')
dragElement document.getElementById('sharpener')
dragElement document.getElementById('pencil-1')
dragElement document.getElementById('clew')
dragElement document.getElementById('clew-color')
dragElement document.getElementById('brush')
dragElement document.getElementById('box')
dragElement document.getElementById('awl')
dragElement document.getElementById('business-card-1')
dragElement document.getElementById('business-card-2')
dragElement document.getElementById('envelope')
dragElement document.getElementById('pencil-2')
# Resize button
(($) ->
$.fn.imageResize = (options) ->
settings =
width: 150
height: 150
options = $.extend(settings, options)
@each ->
$element = $(this)
maxWidth = options.width
maxHeight = options.height
ratio = 0
width = $element.width()
height = $element.height()
if width > maxWidth
ratio = maxWidth / width
$element.css 'width', maxWidth
$element.css 'height', height * ratio
if height > maxHeight
ratio = maxHeight / height
$element.css 'height', maxHeight
$element.css 'width', width * ratio
return
return
) jQuery
a = 9
## Removing the resizing border while moving the object
$('.obj-cont').draggable
start: ->
$(this).find(".obj").css("z-index", a++);
return
drag: ->
return
stop: ->
return
Also see: Tab Triggers