javascript - How to set the initial position of overflow scroll?
phpcn_u1582
phpcn_u1582 2017-05-19 10:16:30
0
2
776

Usetop: 50%; transform: translateY(-50%)Vertically centered p
When the height of p is greater than the parent container, the initial position of the scroll is not the top of the p
Similar to this, please give me some advice. .

phpcn_u1582
phpcn_u1582

reply all(2)
过去多啦不再A梦
$('body').scrollTop(200); // 滚动到离顶部 200 的地方 
$('body').scrollTop($('body')[0].scrollTop); // 滚动到底部 
淡淡烟草味

$('body').scrollTop(‘(current center element height - container height)/2’); Remember to add if height is not greater than the judgment

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template