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
1 Réponse
+ 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';