Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

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.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

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.

+ add another resource

Packages

Add Packages

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.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta name="generator" content="SuperHi">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Animated moving</title>

<link rel="stylesheet" href="index_files/_base.css"><link rel="stylesheet" href="index_files/style.css">

</head>
<body data-gr-c-s-loaded="true" class="vsc-initialized">
 

  <div class="ball" style="left:50%; top: 50%"></div>
  
  <h2 class="woo1">This &nbsp; is Neato!</h2>
  <h2 class="woo2">This is Neato!</h2>
  <h2 class="woo3">This is &nbsp; Neato!</h2>
  
  
  

</body>
              
            
!

CSS

              
                @import url("https://use.typekit.net/jsf7weg.css");

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 100%;
  font: inherit;
  vertical-align: baseline;
  font-family: bebas-neue, sans-serif;
  font-style: normal;
  font-weight: 400;
}

article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
  display: block;
}
body {
  line-height: 1;
  overflow:hidden;
}
ol, ul {
  list-style: none;
}
blockquote, q {
  quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
  content: '';
  content: none;
}
table {
  border-collapse: collapse;
  border-spacing: 0;
}

img, iframe {
  vertical-align: bottom;
  max-width: 100%;
}

input, textarea, select {
  font: inherit;
}

* {
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}


body {
  font-size: 16px;
  font-family: Helvetica;
  line-height: 1.5;

  background-color: #000000;
  color: #ffffff;
}

h1 {
  position: absolute;
  top: 50%;
  left: 50%;
  font-size: 20vmin;
  transform: translate(-50%, -50%);
  text-align: center;
  line-height: 18vmin;
  border: 50px solid white;
  padding: 5rem;
}

@keyframes heartbeat {
  0% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.1); }
  100% { transform: translate(-50%, -50%) scale(1); }
}

div.ball {
  background-color: #ffffff;
  width: 200px;
  height: 200px;
  border-radius: 50%;

  position: absolute;
  top: 0;
  left: 0;
  transform: translate(-50%, -50%);

  mix-blend-mode: difference;
  animation: heartbeat 5s infinite;
}


h2 {

  color: white;
  font-size: 5rem;
  text-align: center;
  width: 100%;
  position: absolute;
  top: 100;
  left: 100;
  transform: translate(50%, 50%);

  mix-blend-mode: exclusion;
  animation: heartbeat 5s infinite;
   cursor: grabbing !important;
}


.woo1
{
  color: rgb(255,0,0);
}
.woo2
{
  color: rgb(0,255,0);
}

.woo3
{
  color: rgb(0,0,255);
}
              
            
!

JS

              
                
let mouseX = 0
let mouseY = 0


const heading1 = document.querySelector("h2.woo1")
let text1X = 0
let text1Y = 0

let text1speed = .08

function animate_text1() {
  let dist1X = mouseX - text1X
  let dist1Y = mouseY - text1Y
  
  text1X = text1X + (dist1X * text1speed)
  text1Y = text1Y + (dist1Y * text1speed)  
  
  heading1.style.left = text1X + "px"
  heading1.style.top = text1Y + "px"
  
  requestAnimationFrame(animate_text1)
}

animate_text1()





const heading2 = document.querySelector("h2.woo2")
let text2X = 0
let text2Y = 0

let text2speed = .04

function animate_text2() {
  let dist2X = mouseX - text2X
  let dist2Y = mouseY - text2Y
  
  text2X = text2X + (dist2X * text2speed)
  text2Y = text2Y + (dist2Y * text2speed)  
  
  heading2.style.left = text2X + "px"
  heading2.style.top = text2Y + "px"
  
  requestAnimationFrame(animate_text2)
}

animate_text2()




const heading3 = document.querySelector("h2.woo3")
let text3X = 0
let text3Y = 0

let text3speed = .12

function animate_text3() {
  let dist3X = mouseX - text3X
  let dist3Y = mouseY - text3Y
  
  text3X = text3X + (dist3X * text3speed)
  text3Y = text3Y + (dist3Y * text3speed)  
  
  heading3.style.left = text3X + "px"
  heading3.style.top = text3Y + "px"
  
  requestAnimationFrame(animate_text3)
}

animate_text3()







document.addEventListener("mousemove", function (event) {
  mouseX = event.pageX
  mouseY = event.pageY
})
              
            
!
999px

Console