Js animation problem

clipboard.png

a.style.left = a.offsetLeft + 10 + "px";
div

console.log(a.style.left+"--"+a.offsetLeft)
a.style.lefta.offsetLeft

clipboard.png


flexstyle.left


clipboard.png
is still the same

Mar.05,2021

do you want to know the location of CSS?

it seems that the subject does not understand the role of these attributes of position display. When position is static, it will not work if you change left. Top right bottom left is not involved in the control of flex layout. If you want the element itself to participate in the flex layout and to animate the displacement of the element, transform should be the first choice. Transform is to make visual changes to the elements after layout, without affecting the layout and positioning itself.


offset is 205, isn't it 215 after adding 10? Both are the original values, and of course they will not change


numeric operations and strings should be separated as follows:

a.style.left = (a.offsetLeft + 10) + 'px'
Menu