JSFiddle - React, Tailwind, and code Playground

by Vipin Patil

CSS

html,body {
    height: 100%;
}

JavaScript

var screenWidth;
var colors = ['red', 'green', 'yellow'];

function onMouseMove(e) {
    var x = e.pageX;
    var color = colors[parseInt(x / screenWidth * colors.length)];
    $(document.body).css('background-color', color);
}

function onResize() {
    screenWidth = $(document).width();
}

$(window).on('mousemove', onMouseMove);
$(window).resize(onResize);
onResize();