Silence-dream / Silence-dream.github.io

blog博客
https://silence-dream.github.io
3 stars 0 forks source link

横向滚动居中 #29

Open Silence-dream opened 1 year ago

Silence-dream commented 1 year ago

当前元素offsetLeft + (当前元素宽度的一半 - 屏幕宽度的一半)

element.offsetLeft + (element.clientWidth / 2 - screen.width / 2),