0

Animation

function move() { pos += 1; box.style.left = pos+"px"; //px = pixels } what I don't understand is pos + "px" what does it mean

4th Jul 2017, 10:20 PM
van persie
van persie - avatar
1 Resposta
+ 3
box.style.left takes a string as value. pos + 'px' is a concatination of 1 und 'px'. So the value is '1px'. 'left' is a css attribute and needs a number followed by a unit. e.g.: 1px; 1em; 1rem; 1%; box.style.left = '1px';
4th Jul 2017, 10:24 PM
Bumpety