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.
<ul class="social-share">
<li><a href="#" class="twitter"><div></div><span class="screen-reader-text">Twitter</span><svg viewBox="0 0 512 512"><path d="M419.6 168.6c-11.7 5.2-24.2 8.7-37.4 10.2 13.4-8.1 23.8-20.8 28.6-36 -12.6 7.5-26.5 12.9-41.3 15.8 -11.9-12.6-28.8-20.6-47.5-20.6 -42 0-72.9 39.2-63.4 79.9 -54.1-2.7-102.1-28.6-134.2-68 -17 29.2-8.8 67.5 20.1 86.9 -10.7-0.3-20.7-3.3-29.5-8.1 -0.7 30.2 20.9 58.4 52.2 64.6 -9.2 2.5-19.2 3.1-29.4 1.1 8.3 25.9 32.3 44.7 60.8 45.2 -27.4 21.4-61.8 31-96.4 27 28.8 18.5 63 29.2 99.8 29.2 120.8 0 189.1-102.1 185-193.6C399.9 193.1 410.9 181.7 419.6 168.6z"/></svg></a></li>
<li><a href="#" class="facebook"><div></div><span class="screen-reader-text">Facebook</span><svg viewBox="0 0 512 512"><path d="M211.9 197.4h-36.7v59.9h36.7V433.1h70.5V256.5h49.2l5.2-59.1h-54.4c0 0 0-22.1 0-33.7 0-13.9 2.8-19.5 16.3-19.5 10.9 0 38.2 0 38.2 0V82.9c0 0-40.2 0-48.8 0 -52.5 0-76.1 23.1-76.1 67.3C211.9 188.8 211.9 197.4 211.9 197.4z"/></svg></a></li>
<li><a href="#" class="instagram"><div></div><span class="screen-reader-text">Instagram</span><svg viewBox="0 0 512 512"><path d="M365.3 234.1h-24.7c1.8 7 2.9 14.3 2.9 21.9 0 48.3-39.2 87.5-87.5 87.5 -48.3 0-87.5-39.2-87.5-87.5 0-7.6 1.1-14.9 2.9-21.9h-24.7V354.4c0 6 4.9 10.9 10.9 10.9H354.4c6 0 10.9-4.9 10.9-10.9V234.1H365.3zM365.3 157.6c0-6-4.9-10.9-10.9-10.9h-32.8c-6 0-10.9 4.9-10.9 10.9v32.8c0 6 4.9 10.9 10.9 10.9h32.8c6 0 10.9-4.9 10.9-10.9V157.6zM256 201.3c-30.2 0-54.7 24.5-54.7 54.7 0 30.2 24.5 54.7 54.7 54.7 30.2 0 54.7-24.5 54.7-54.7C310.7 225.8 286.2 201.3 256 201.3M365.3 398.1H146.7c-18.1 0-32.8-14.7-32.8-32.8V146.7c0-18.1 14.7-32.8 32.8-32.8h218.7c18.1 0 32.8 14.7 32.8 32.8v218.7C398.1 383.4 383.5 398.1 365.3 398.1"/></svg></a></li>
</ul>
body,
html {
height: 100%;
}
body {
align-items: center;
display: flex;
justify-content: center;
background-image: linear-gradient(45deg, #E1F5C4, #EDE574);
}
.screen-reader-text {
overflow: hidden;
position: absolute;
height: 1px;
width: 1px;
clip: rect(1px, 1px, 1px, 1px);
}
ul,
li{
padding: 0;
margin: 0;
list-style: none;
}
svg {
position: relative;
height: 30px;
width: 50px;
z-index: 5;
fill: #333;
transition: 300ms;
}
.social-share {
display: flex;
justify-content: space-between;
min-width: 200px;
position: relative;
background-image: linear-gradient(-45deg, rgba(#EDE574, 0.6), rgba(#E1F5C4, 0.6));
border: 1px solid #fefefe;
a > div {
position: absolute;
// background: rgba(75,75,75,0.7);
width: 100%;
height: 100%;
left: -100%;
z-index: 1;
}
a {
display: block;
overflow: hidden;
position: relative;
padding: 15px;
&:hover {
svg {
fill: #efefef;
}
}
&.twitter {
> div {
background: #00aced;
}
}
&.facebook {
> div {
background: #3b5998;
}
}
&.instagram {
> div {
background: #517fa4;
}
}
}
}
/**
* jquery.hoverdir.js v1.1.0
* http://www.codrops.com
*
* Licensed under the MIT license.
* https://www.opensource.org/licenses/mit-license.php
*
* Copyright 2012, Codrops
* http://www.codrops.com
*/
;
(function($, window, undefined) {
'use strict';
$.HoverDir = function(options, element) {
this.$el = $(element);
this._init(options);
};
// the options
$.HoverDir.defaults = {
speed: 300,
easing: 'ease',
hoverDelay: 0,
inverse: false
};
$.HoverDir.prototype = {
_init: function(options) {
// options
this.options = $.extend(true, {}, $.HoverDir.defaults, options);
// transition properties
this.transitionProp = 'all ' + this.options.speed + 'ms ' + this.options.easing;
// load the events
this._loadEvents();
},
_loadEvents: function() {
var self = this;
this.$el.on('mouseenter.hoverdir, mouseleave.hoverdir', function(event) {
var $el = $(this),
$hoverElem = $el.find('div'),
direction = self._getDir($el, {
x: event.pageX,
y: event.pageY
}),
styleCSS = self._getStyle(direction);
if (event.type === 'mouseenter') {
$hoverElem.hide().css(styleCSS.from);
clearTimeout(self.tmhover);
self.tmhover = setTimeout(function() {
$hoverElem.show(0, function() {
var $el = $(this);
if (self.support) {
$el.css('transition', self.transitionProp);
}
self._applyAnimation($el, styleCSS.to, self.options.speed);
});
}, self.options.hoverDelay);
} else {
if (self.support) {
$hoverElem.css('transition', self.transitionProp);
}
clearTimeout(self.tmhover);
self._applyAnimation($hoverElem, styleCSS.from, self.options.speed);
}
});
},
// credits : http://stackoverflow.com/a/3647634
_getDir: function($el, coordinates) {
// the width and height of the current div
var w = $el.width(),
h = $el.height(),
// calculate the x and y to get an angle to the center of the div from that x and y.
// gets the x value relative to the center of the DIV and "normalize" it
x = (coordinates.x - $el.offset().left - (w / 2)) * (w > h ? (h / w) : 1),
y = (coordinates.y - $el.offset().top - (h / 2)) * (h > w ? (w / h) : 1),
// the angle and the direction from where the mouse came in/went out clockwise (TRBL=0123);
// first calculate the angle of the point,
// add 180 deg to get rid of the negative values
// divide by 90 to get the quadrant
// add 3 and do a modulo by 4 to shift the quadrants to a proper clockwise TRBL (top/right/bottom/left) **/
direction = Math.round((((Math.atan2(y, x) * (180 / Math.PI)) + 180) / 90) + 3) % 4;
return direction;
},
_getStyle: function(direction) {
var fromStyle, toStyle,
slideFromTop = {
left: '0px',
top: '-100%'
},
slideFromBottom = {
left: '0px',
top: '100%'
},
slideFromLeft = {
left: '-100%',
top: '0px'
},
slideFromRight = {
left: '100%',
top: '0px'
},
slideTop = {
top: '0px'
},
slideLeft = {
left: '0px'
};
switch (direction) {
case 0:
// from top
fromStyle = !this.options.inverse ? slideFromTop : slideFromBottom;
toStyle = slideTop;
break;
case 1:
// from right
fromStyle = !this.options.inverse ? slideFromRight : slideFromLeft;
toStyle = slideLeft;
break;
case 2:
// from bottom
fromStyle = !this.options.inverse ? slideFromBottom : slideFromTop;
toStyle = slideTop;
break;
case 3:
// from left
fromStyle = !this.options.inverse ? slideFromLeft : slideFromRight;
toStyle = slideLeft;
break;
};
return {
from: fromStyle,
to: toStyle
};
},
_applyAnimation: function(el, styleCSS, speed) {
$.fn.applyStyle = this.support ? $.fn.css : $.fn.animate;
el.stop().applyStyle(styleCSS, $.extend(true, [], {
duration: speed + 'ms'
}));
},
};
var logError = function(message) {
if (window.console) {
window.console.error(message);
}
};
$.fn.hoverdir = function(options) {
var instance = $.data(this, 'hoverdir');
if (typeof options === 'string') {
var args = Array.prototype.slice.call(arguments, 1);
this.each(function() {
if (!instance) {
logError("cannot call methods on hoverdir prior to initialization; " +
"attempted to call method '" + options + "'");
return;
}
if (!$.isFunction(instance[options]) || options.charAt(0) === "_") {
logError("no such method '" + options + "' for hoverdir instance");
return;
}
instance[options].apply(instance, args);
});
} else {
this.each(function() {
if (instance) {
instance._init();
} else {
instance = $.data(this, 'hoverdir', new $.HoverDir(options, this));
}
});
}
return instance;
};
})(jQuery, window);
$(function() {
$(' .social-share > li ').each(function() {
$(this).hoverdir();
});
});
Also see: Tab Triggers