cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation


Save Automatically?

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.

              <figure id="pointer-container">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/pink-pointer.svg" alt id="pointer">
              * {
  box-sizing: border-box;

body {
  overflow: hidden;
 // just used to stop the scrollbar freaking out as the element turns
  min-height: 100vh;

#pointer-container {
  margin: 3rem;
  margin-bottom: 0;

#pointer {
  width: 25%;
  height: auto;
  transform-origin: center 59%;
  display: block;
  margin: 0 auto;
  touch-action: none;
              document.addEventListener("DOMContentLoaded", function() {
		var pointer = document.getElementById("pointer"),
		pointerBox = pointer.getBoundingClientRect(),
		centerPoint = window.getComputedStyle(pointer).transformOrigin,
		centers = centerPoint.split(" ");

	function rotatePointer(e) {
    var pointerEvent = e;
       if (e.targetTouches && e.targetTouches[0]) {
          pointerEvent = e.targetTouches[0];
          mouseX = pointerEvent.pageX;
          mouseY = pointerEvent.pageY;
    } else {
          mouseX = e.clientX,
          mouseY = e.clientY;

		var centerY = pointerBox.top + parseInt(centers[1]) - window.pageYOffset,
		centerX = pointerBox.left + parseInt(centers[0]) - window.pageXOffset,
    		radians = Math.atan2(mouseX - centerX, mouseY - centerY),
    		degrees = (radians * (180 / Math.PI) * -1) + 180; 
    		pointer.style.transform = 'rotate('+degrees+'deg)';

window.addEventListener('mousemove', rotatePointer);
window.addEventListener('touchmove', rotatePointer);
window.addEventListener('touchstart', rotatePointer);

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.


Loading ..................