Commit e86908eb authored by Benjamin Gallois's avatar Benjamin Gallois

Moving white circle on black background

parents
feteDeLaScience
var circle = document.getElementById('circle');
var circleX = 0;
var circleY = 0;
function move(event) {
var x = event.clientX;
var y = event.clientY;
var a = circle.offsetWidth;
var buttonPressed = event.buttons
if (buttonPressed == 1){
circle.style.left = x - a/2 + 'px';
circle.style.top = y - a/2 + 'px';
}
}
#circle {
width: 200px;
height: 200px;
border-radius: 50%;
background-color: white;
position: relative;
}
body {
background-color: black;
color: white;
}
<html>
<head>
<title>Phototaxis fête de la science</title>
<link rel="stylesheet" type="text/css" href="main.css">
</head>
<body onmousemove="move(event)">
<div id="circle"></div>
<script src="app.js" type="text/javascript"></script>
</body>
</html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment