<pre><code>div::after {
  counter-reset: mouse-x var(--mouse-x) mouse-y var(--mouse-y);
  content: counter(mouse-x) "px, " counter(mouse-y) "px";
}</code></pre>

<!-- Info bubble -->
<div></div>
:root {
  --mouse-x: 200;
  --mouse-y: 200;
}

/* See: http://stackoverflow.com/q/40164169/4172644*/
div::after {
  counter-reset: mouse-x var(--mouse-x) mouse-y var(--mouse-y);
  content: counter(mouse-x) "px, " counter(mouse-y) "px";
}











/* setup and presentation styles */
div::before {
  content: 'mouse position';
  font-weight: bold;
}
div {
  position: fixed;
  top: 0;
  left: 0;
  transform: translate(calc(var(--mouse-x) * 1px), calc(var(--mouse-y) * 1px));
  width: 10em;
  height: 10em;
  background: #9ccf5e;
  color: #fff;
  display: flex;
  flex-flow: column;
  align-items: center;
  justify-content: center;
  line-height: 2;
  border-radius: 100%;
  will-change: transform;
}
body {
  margin: 2em;
  font-family: sans-serif;
}
document.addEventListener('mousemove', (e) => {
  document.documentElement.style.setProperty('--mouse-x', e.clientX)
  document.documentElement.style.setProperty('--mouse-y', e.clientY)
})

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.