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.
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<div class="intro">
<h1>Motion Blur Experiment</h1>
<h2>by <a href="https://codepen.io/lbebber">Lucas Bebber</a></h2>
<p>Click on the button below</p>
</div>
<button class="open-modal">Open Modal</button>
<div class="modal-overlay"></div>
<div class="modal">
<button class="close-modal">×</button>
<div class="icon">
<i class="fa fa-user-plus"></i>
</div>
<h1>Some Title</h1>
<input class="input-text" type="text" placeholder="some field"/>
<input class="input-text" type="text" placeholder="some other field"/>
<input class="input-submit" type="submit" value="Some Button"/>
</div>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" class="filters">
<defs>
<filter id="blur">
<feGaussianBlur id="blur-filter" in="SourceGraphic" stdDeviation="0,0" />
</filter>
</defs>
</svg>
@import url(https://fonts.googleapis.com/css?family=Roboto:400,700,300)
font-roboto="Roboto", sans-serif
white=#eeeaea
black=#333344
grey=#cdcccc
gray=grey
red=#cc4411
absolute-fill()
position absolute
top 0
left 0
bottom 0
right 0
$default-button
background red
border none
color white
font-family font-roboto
font-weight 700
outline none
*
box-sizing border-box
a
color inherit
body
background white
color black
font-family roboto
overflow hidden
&::before
content ""
display none
absolute-fill()
background rgba(10,0,0,0.1)
h1, h2, h3
font-weight 300
margin 0
.icon
font-size 60px
color red
.modal-overlay
background alpha(black,0.4)
absolute-fill()
opacity 0
visibility hidden
.modal
background white
text-align center
width 230px
height 320px
absolute-fill()
border-radius 3px
margin auto
padding 20px
//box-shadow 0px 8px 13px 6px rgba(0,0,0,0.03);
filter url('#blur')
transform translate3d(0,-900%,0);
h1
margin-bottom 20px
input
margin-bottom 10px
padding 10px
font-family roboto
border none
width 100%
&.input-text
background white
border-bottom 2px solid gray
outline none
color black
&:focus
border-bottom-color red
&::placeholder
color black
&.input-submit
@extend $default-button
margin-top 10px
.close-modal
background none
border none
position absolute
font-size 20px
right 10px
top 10px
color black
outline none
.open-modal
absolute-fill()
width 200px
height 40px
margin auto
@extend $default-button
.intro
text-align center
absolute-fill()
margin auto
height 120px
transform translate(0,-90px)
.filters
position absolute
width 0
height 0
$(document).ready(function(){
var $obj=$(".modal")
,$overlay=$(".modal-overlay")
,blur=$("#blur-filter").get(0)
;
function setBlur(v){
blur.setAttribute("stdDeviation", v);
}
function getPos(){
return $obj.position();
}
var lastPos=getPos();
function update(){
var pos=getPos();
var limit=20;
var dx=Math.min(limit,Math.abs(pos.left-lastPos.left)*0.5);
var dy=Math.min(limit,Math.abs(pos.top-lastPos.top)*0.5);
setBlur(dx+","+dy);
lastPos=pos;
requestAnimationFrame(update);
}
update();
var isOpen=false;
function openModal(){
/*$overlay.css({
display:"block"
})*/
TweenMax.to($overlay,0.1,{autoAlpha:1});
TweenMax.fromTo($obj,0.6,{y:-($(window).height()+$obj.height())},{delay:0.2,y:"0%",ease:Elastic.easeOut,easeParams:[1.1,0.7],force3D:true});
}
function closeModal(){
TweenMax.to($overlay,0.1,{delay:0.55,autoAlpha:0});
TweenMax.to($obj,0.55,{y:$(window).height()+$obj.height(),ease:Back.easeIn,force3D:true});
}
$(".open-modal").click(function(){
openModal();
})
$(".close-modal,.modal-overlay,.input-submit").click(function(){
closeModal();
})
})
Also see: Tab Triggers