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.
<div id="container">
<div class="content">
<h1>Your reaction?</h1>
<div class="reaction">
<div class="emoji">😺</div>
<div class="count">52</div>
<div class="text">happy</div>
</div>
<div class="reaction">
<div class="emoji">😹</div>
<div class="text">amused</div>
<div class="count">1361</div>
</div>
<div class="reaction">
<div class="emoji">😻</div>
<div class="text">in love</div>
<div class="count">94</div>
</div>
<div class="reaction">
<div class="emoji">🙀</div>
<div class="text">shocked</div>
<div class="count">5</div>
</div>
<div class="reaction">
<div class="emoji">😼</div>
<div class="text">angry</div>
<div class="count">17</div>
</div>
<div class="reaction">
<div class="emoji">😿</div>
<div class="text">sad</div>
<div class="count">0</div>
</div>
<div class="settings">
<strong>Share buttons:</strong>
<input type="radio" name="settings" value="popup" id="popup" checked><label for="popup">Popup</label>
<input type="radio" name="settings" value="tooltip" id="tooltip"><label for="tooltip">Tooltip</label>
<input type="radio" name="settings" value="none" id="none"><label for="none">None</label>
</div>
</div>
</div>
<div class="hidden" id="modal">
<a class="fa fa-close" onclick="closeModal()"></a>
<h2>Share your feelings!</h2>
<h3 id="modalcontent">Let your friends know what you think.</h3>
<div class="social">
<a class="fa fa-facebook" href="https://www.facebook.com/sharer.php?u=https://codepen.io/inesmontani/full/XmzeYr&t=Reaction emojis with social sharing & animation" target="_blank"></a>
<a class="fa fa-twitter" href="https://twitter.com/share?text=Reaction emojis with social sharing & animation &url=https://codepen.io/inesmontani/full/XmzeYr&via=klammerauf" target="_blank"></a>
<a class="fa fa-tumblr" href="https://www.tumblr.com/share/link?url=https://codepen.io/inesmontani/full/XmzeYr" target="_blank"></a>
</div>
</div>
@import url(https://fonts.googleapis.com/css?family=Muli:400,300|Merriweather:400,300,700)
$background: #564787
$accent: #ffa630
$light: #ccc
$dark: #222
body
width: 100vw
height: 100vh
display: table
background: $background
margin: 0
#container
display: table-cell
vertical-align: middle
text-align: center
.content
background: white
padding: 1em 0 1em 0
.reaction
display: inline-block
position: relative
text-align: center
margin: 1em 0 0 0
&:hover
.emoji
transform: scale(1.1, 1.1)
transition: all .1s
.text
color: #222
transition: all .1s
.emoji
font-size: 4em
cursor: pointer
.count
position: absolute
top: -1em
right: 0
border-radius: 1.75em
min-width: 1.25em
height: 1.75em
font: 600 .9em "Muli", arial, sans-serif
background: $accent
color: white
border: .25em solid white
padding: 0 .25em
cursor: pointer
.text
font: 400 1em/2.5em "Muli", arial, sans-serif
color: $light
cursor: pointer
h1,
h2
font: 700 2em/3em "Merriweather", georgia, serif
text-align: center
color: $dark
h2
line-height: 1.25em
margin: 1.5em 0 0 0
h3
font: 300 1em/2.5em "Muli", arial, sans-serif
text-align: center
color: darken($light, 15%)
margin: 0 0 2.5em 0
#modal
position: absolute
background: white
border: 1px solid lighten($light, 5%)
box-shadow: 0 0 .25em $light
.popup
bottom: 0
right: 0
margin: auto
width: 500px
height: 275px
.tooltip
position: absolute
top: 26em
left: 7.5em
width: 275px
font-size: .8em
padding: 0 1em 1em 1em
margin: 0 0 3em 0
border-radius: 1.5em
&:after
display: block
content: ""
position: absolute
top: .15em
left: 0
right: 0
width: 0
height: 0
margin: auto
border-width: .75em
border-style: solid
border-color: transparent transparent white white
box-shadow: .1em -.1em .25em $light
background: white
transform-origin: 0 0
transform: rotate(-45deg)
z-index: 100 !important
h2
margin: .75em 0 0 0
h3
margin: .75em 0 1.5em 0
line-height: 1.25em
.social
font-size: 1.75em
.fa-close
bottom: -.75em
font-size: 1.25em
.fa-close
display: inline-block
position: absolute
top: -.75em
right: -.75em
text-align: center
text-decoration: none
color: $dark
background: white
border: 1px solid lighten($light, 5%)
border-radius: 50%
width: 1.25em
height: 1.25em
padding: .25em
cursor: pointer
.social
font-size: 2.5em
text-align: center
.fa
width: 1em
text-decoration: none
background: $dark
color: white
margin: 0 .15em
padding: .25em
&:hover
opacity: .9
.fa-facebook
background: #3765a3
.fa-twitter
background: #6cadde
.fa-tumblr
background: #1c2f44
.animate
animation: bounce .5s
.hidden
visibility: hidden
pointer-events: none
.settings
font: 300 .85em "Muli", arial, sans-serif
color: $dark
margin: 3em 0 0 0
padding: 1em 0 0 0
input[type="radio"]
display: none
input[type="radio"] + label:before
content: ""
display: inline-block
border: 2px solid $background
width: .75em
height: .75em
margin: 0 .5em 0 0
vertical-align: middle
cursor: pointer
border-radius: 50%
input[type="radio"] + label:before
background: white
input[type="radio"]:checked + label:before
background: $background
label
margin: 0 1em 0 .5em
cursor: pointer
// Thanks to animate.css!
@keyframes bounce
from, 20%, 40%, 60%, 80%, to
animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000)
20%
transform: scale3d(1.1, 1.1, 1.1)
40%
transform: scale3d(.9, .9, .9)
60%
transform: scale3d(1.03, 1.03, 1.03)
80%
transform: scale3d(.97, .97, .97)
to
transform: scale3d(1, 1, 1)
// using the same JS as here: https://codepen.io/inesmontani/pen/OyOEWg
Also see: Tab Triggers