CSS
html, body {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
background: #F4F4F4;
display: flex;
justify-content: center;
align-items: center;
}
.wrapper {
margin-top: 50px;
display: inline-block;
position: relative;
background: tomato;
border-radius: 50%;
background-size: cover;
width: 300px;
height: 300px;
overflow: hidden;
z-index: 1;
}
.inner {
position: absolute;
left: -25%;
bottom: 50%;
width: 150%;
height: 50%;
transform-origin: bottom center;
overflow: hidden;
}
.inner div {
top: 0%;
height: 200%;
width: 100%;
background-color: #2980b9;
}
.overlay {
position: absolute;
top: 50%;
left: 50%;
margin-top: -75px;
margin-left: -75px;
width: 150px;
height: 150px;
background: #F4F4F4;
border-radius: 50%;
}
.overlay:before {
content: '';
position: absolute;
width: 170%;
height: 170%;
border-radius: 50%;
margin-top: -68px;
margin-left: -68px;
border: 15px solid #F4F4F4;
}
.overlay div {
position: absolute;
top: 60%;
left: 50%;
width: 70px;
height: 70px;
overflow: hidden;
background: tomato;
margin-top: -35px;
margin-left: -35px;
}
.overlay div:before {
content: '';
position: absolute;
left: -80%;
height: 120%;
width: 80%;
background: #F4F4F4;
transform-origin: top right;
transform: rotate(-33deg);
}
.overlay div:after {
content: '';
position: absolute;
right: -80%;
height: 120%;
width: 80%;
background: #F4F4F4;
transform-origin: top left;
transform: rotate(33deg);
}
JAVASCRIPT
window.onload = function() {
var wrapper = document.querySelectorAll('.jsFollow'),
inner = document.querySelectorAll('.jsFollow > .inner')
innerDivs = document.querySelectorAll('.jsFollow > .inner > div');
window.onmousemove = rotateElems;
function rotateElems(e) {
var mouseX = e.pageX,
mouseY = e.pageY;
for(var i=0; i < inner.length; i++) {
var outer = wrapper[i],
inerElm = inner[i],
innerDiv = innerDivs[i],
centerX = outer.offsetLeft + (outer.clientWidth / 2),
centerY = outer.offsetTop + (outer.clientHeight / 2),
degree = Math.atan2(mouseX - centerX, - (mouseY - centerY) )*(180/Math.PI);
inerElm.style.webkitTransform = "rotate(" + degree + "deg)";
inerElm.style.transform = "rotate(" + degree + "deg)";
degree = -degree;
innerDiv.style.webkitTransform = "rotate(" + degree + "deg)";
innerDiv.style.transform = "rotate(" + degree + "deg)";
}
}
}