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.
// TODO add trigger to btn 2
// * INSPIRED BY PHIL HOYT *
.title
h1 Call to Action Experiment
.separator
.container
.btn.btn1.ripple-effect
.text Call to Action
.icon.fa.fa-arrow-right
.btn.btn2.ripple-effect
.text Call to Action
.icon.fa.fa-arrow-right
.side-note A pen by
a(href='https://www.codepen.io/guywald' target='_blank') Guy Waldman
// import Roboto Font
@import "https://fonts.googleapis.com/css?family=Roboto:400,100,100italic,300,300italic,400italic,500,500italic,700,700italic,900,900italic&subset=latin,cyrillic"
$bgColor: lighten(#DFECE6,20%)
$accentColor1: #3CA2A2
$accentColor2: #215A6D
$accentColor3: #2D2D29
// -----
$btnWidth: 130px
$btnHeight: 30px
body
font-family: 'Roboto', sans-serif
background-color: $bgColor
display: flex
flex-direction: column
align-items: center
justify-content: space-around
// ------------------------
.side-note
position: absolute
left: 10px
top: 10px
font-weight: 300
font-size: .7em
color: #888
a
cursor: default
text-decoration: underline
color: inherit
font-weight: 500
transition: color 300ms ease
&:hover
color: #555
.container
height: 75vh
display: flex
flex-direction: column
align-items: center
justify-content: center
.title
margin-top: $btnHeight
height: 15vh
display: flex
justify-content: center
align-items: center
flex-direction: column
text-align: center
h1
color: $accentColor3
font-weight: 500
font-size: 2em
margin: 5px
h2
margin: $btnHeight/2
margin-top: 0
color: lighten($accentColor3, 20%)
font-weight: 300
font-size: 1em
.separator
display: block
background-color: lighten($accentColor3, 20%)
margin: $btnHeight/2
height: 1px
width: $btnWidth/2
.btn
position: relative
margin: $btnHeight/2
user-select: none
cursor: default
display: block
text-align: center
border: 1px solid $accentColor1
width: $btnWidth
height: $btnHeight
border-radius: 5px
padding: 10px 25px
box-shadow: 0 0 5px 0 rgba($accentColor1,.15)
line-height: $btnHeight
.text, .icon
font-size: .7em
text-align: center
text-transform: uppercase
color: $accentColor1
font-weight: 500
// --------------------------------------
.btn.btn1
border-color: $accentColor1
box-shadow: 0 0 5px 0 rgba($accentColor1,.15)
.text, .icon
color: $accentColor1
transition: all 300ms ease
overflow: hidden
.ink
background: $accentColor1
.text
position: relative
bottom: 0
opacity: 1
transition: all 300ms ease
.icon
position: relative
opacity: 0
bottom: 0
transition: all 300ms ease
&.clicked
animation: growAndShrink 300ms ease-in-out
&:hover
background-color: rgba($accentColor1,.1)
.text
bottom: $btnHeight
opacity: 0
.icon
opacity: 1
bottom: $btnHeight
.btn.btn2
white-space: nowrap
border-color: $accentColor2
box-shadow: 0 0 5px 0 rgba($accentColor2,.15)
.text, .icon
transition: all 300ms ease
color: $accentColor2
transition: all 300ms ease
overflow: hidden
// animation: myFrames 300ms ease-out reverse forwards
.ink
background: $accentColor2
.text
position: relative
left: 0
opacity: 1
.icon
position: relative
transform: rotate(60deg)
bottom: $btnHeight
right: $btnWidth
opacity: 0
&:hover
background-color: rgba($accentColor2,.1)
.text
left: $btnWidth
opacity: 0
.icon
transform: rotate(0)
right: 0
opacity: 1
@keyframes growAndShrink
0%
transform: scale(1)
50%
transform: scale(1.3)
100%
transform: scale(1)
// ------------ RIPPLE EFFECT ---------------
.ripple-effect
position: relative
overflow: hidden
transform: translatez(0)
.ripple-effect .ink
display: block
position: absolute
pointer-events: none
border-radius: 50%
transform: scale(0)
background: $accentColor1
opacity: .2
&.animate
animation: ripple-effect 0.5s linear
@keyframes ripple-effect
100%
opacity: 0
transform: scale(2.5)
// adds "clicked" class to icon when button is clicked
$(".btn").each(function(){
$(this).click(function(event) {
console.log("clicked");
var icon = $(this).find(".icon");
icon.removeClass("clicked").width(); // forces reflow of element
icon.addClass("clicked");
});
});
// ----------- RIPPLE EFFECT ------------
/**
* Created by Kupletsky Sergey on 04.09.14.
*
* Ripple-effect animation
* Tested and working in: ?IE9+, Chrome (Mobile + Desktop), ?Safari, ?Opera, ?Firefox.
* JQuery plugin add .ink span in element with class .ripple-effect
* Animation work on CSS3 by add/remove class .animate to .ink span
*/
$(".ripple-effect").each(function(){
$(this).click(function(e) {
var rippler = $(this);
// create .ink element if it doesn't exist
if (rippler.find(".ink").length == 0) {
rippler.prepend("<div class='ink'></div>");
}
var ink = rippler.find(".ink");
// prevent quick double clicks
ink.removeClass("animate");
// set .ink diametr
if (!ink.height() && !ink.width()) {
var d = Math.max(rippler.outerWidth(), rippler.outerHeight());
ink.css({
height: d,
width: d
});
}
// get click coordinates
var x = e.pageX - rippler.offset().left - ink.width() / 2;
var y = e.pageY - rippler.offset().top - ink.height() / 2;
// set .ink position and add class .animate
ink.css({
top: y + 'px',
left: x + 'px'
}).addClass("animate");
})
});
Also see: Tab Triggers