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 URL's added here will be added as <link>
s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.
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.
If the stylesheet 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 CSS 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.
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.
<!--
PLEASE NOTE:
YOU NEED GOOGLE CHROME TO PROPERLY VIEW THIS ANIMATION
-->
<!-- Elements -->
<div class="wrapper">
<div class="mouse"></div>
<div class="random-elements">
<div class="random one circle not-clicked"></div>
<div class="random two circle not-clicked"></div>
<div class="random three triangle not-clicked"></div>
<div class="random four rectangle not-clicked"></div>
</div>
<span class="trigger not-clicked">Click!</span>
</div>
<!-- My details -->
<h1>bleeding effect</h1>
<div class="profile">
<img src="https://scontent-cai1-1.xx.fbcdn.net/v/t1.0-9/7496_1137108913027953_8040503405200721033_n.jpg?oh=c1749cddd1845b0aa0ad9da397fa2294&oe=58111E00" alt="Profile Image" />
<h3>Made by <a target="_blank" href="https://www.facebook.com/Eslam.nasser.yousef">Eslam nasser</a></h3>
<p>
Another cool <a target="_blank" href="https://codepen.io/eslam-nasser/pen/VexqvG">SVG!</a>
</p>
</div>
<!-- SVG Filters -->
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<defs>
<!-- This is where the magic happens -->
<filter id="sticky">
<!-- Apply 10px blur -->
<feGaussianBlur in="SourceGraphic" stdDeviation="12" result="blured" />
<!-- Increase the contrast of the alpha channel
Read this https://goo.gl/P152Jd -->
<feColorMatrix in="blured" mode="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 19 -9" result="weirdNumbers" />
<!-- Adding the two effects,
Fix some bugs with "atop" -->
<feComposite in="SourceGraphic" in2="weirdNumbers" operator="atop"/>
</filter>
</defs>
</svg>
// Some general stuff
@import 'https://fonts.googleapis.com/css?family=Poiret+One|Roboto+Condensed'
body, html
cursor: none
overflow: hidden
background:
color: #34495e
image: url('https://s10.postimg.org/jbhjp29qh/3_min.png')
font-family: 'Poiret One', cursive
// Pen Details
h1
text-align: center
color: #FFF
position: relative
z-index: 3
text-transform: uppercase
font:
weight: 100
size: 60px
.profile
position: absolute
width: 30%
bottom: 20px
left: 50%
margin-left: -15%
z-index: 3
img
width: 20%
border-radius: 100%
float: left
margin: auto 5%
h3, p
width: 70%
float: left
color: #FFF
padding: 0
h3
margin-bottom: 0
font:
size: 22px
p
margin-top: 5px
a
color: #FFF
// Vars
$elements_color: #e74c3c
$elements_shadow: none // Add shadow if you want 0px 2px 5px 0px rgba(0,0,0,0.16),0px 2px 5px 0px rgba(0,0,0,0.23)
// Must apply the svg filter to the parent
.wrapper
filter: url('#sticky') // The id of the filter
position: absolute
top: 0
right: 0
left: 0
bottom: 0
width: 100%
height: 100%
z-index: 3
span.trigger
position: absolute
display: block
width: 100px
color: #FFF
text-transform: uppercase
top: 48%
left: 50%
margin-left: -50px
text-align: center
font-size: 25px
// Mouse
.mouse
width: 60px
height: 60px
border-radius: 100%
background: $elements_color
box-shadow: $elements_shadow
will-change: transform // Read this https://goo.gl/yYc589
.random
width: 100px
height: 100px
margin: 100px
background: $elements_color
box-shadow: $elements_shadow
position: absolute
top: 50%
left: 50%
margin-left: -50px
margin-top: -50px
transition: 4s
transform: translate3d(0,0,0)
transform-origin: center center
will-change: transform, transition // Read this https://goo.gl/yYc589
.random.circle
border-radius: 100%
.random.triangle
width: 0
height: 0
background: transparent
border-left: 50px solid transparent
border-right: 50px solid transparent
border-bottom: 100px solid $elements_color
box-shadow: none
// Trace the mouse
// Some vars to start with
var mouse = $('.mouse'),
currentX = 0,
currentY = 0,
newX = 0,
newY = 0;
// Get X and Y positions
$(window).mousemove(function(e){
currentX = e.pageX; // Get the mouse X position
currentY = e.pageY; // Get the mouse Y position
});
// Make the trace a little bit smooth
var fps = setInterval(function(){
newX += (currentX - newX) / 5; // Create new X position
newY += (currentY - newY) / 5; // Create new Y position
mouse.css({
'transform': 'translate3d('+(newX - 30)+'px, '+(newY - 30)+'px, 0)' // ALWAYS use transform property to get the best performance
});
// console.log('My current Y location is (' +newY+ ') and in X is ('+newX+')' )
}, 16);// Refresh the positions each 16ms to get ~60fps
// Moving the elements randomly functions
// NOTE : THIS HAVE BAD PREFORMANCE DELETE IF YOU NEED 60fps
// Trigger the movement
$('.random.not-clicked, .trigger.not-clicked').click(function(){
movingElements();
$('.not-clicked').removeClass('not-clicked');
});
function makeNewPosition(){
// All this vars to generate different values for each element
var windowHeight = ( $(window).height() - ( $(window).height() / 2 ) ),
windowWidth = ( $(window).width() - ( $(window).width() / 2 ) ),
randomHeight1 = Math.floor(Math.random() * windowHeight),
randomHeight2 = Math.floor(Math.random() * windowHeight),
randomHeight3 = Math.floor(Math.random() * windowHeight),
randomHeight4 = Math.floor(Math.random() * windowHeight),
randomWidth1 = Math.floor(Math.random() * windowWidth),
randomWidth2 = Math.floor(Math.random() * windowWidth),
randomWidth3 = Math.floor(Math.random() * windowWidth),
randomWidth4 = Math.floor(Math.random() * windowWidth);
return [randomHeight1, randomHeight2, randomHeight3, randomHeight4, randomWidth1, randomWidth2, randomWidth3, randomWidth4];
}
function movingElements(){
var newq = makeNewPosition();
$('.random.one').css({'transform': 'translate3d('+newq[4]+'px,-'+newq[0]+'px, 0)'});
$('.random.two').css({'transform': 'translate3d(-'+newq[1]+'px,'+newq[5]+'px, 0)'});
$('.random.three').css({'transform': 'translate3d('+newq[6]+'px,-'+newq[2]+'px, 0)'});
$('.random.four').css({'transform': 'translate3d(-'+newq[3]+'px,'+newq[7]+'px, 0)'});
setTimeout( function() {
movingElements();
}, 3000);
};
Also see: Tab Triggers