【发布时间】:2017-12-02 08:54:45
【问题描述】:
我正在使用从该页面获得的代码 - Flip div with two sides of html,并试图让旋转的 div 在旋转时缓慢滚动到顶部。 (第 2 面)这是我目前在 this page 尝试的。
$('#back').click(function (e) { //#A_ID is an example. Use the id of your Anchor
$('html, body').animate({
scrollTop: $('#side-2').offset().top - 20 //#DIV_ID is an example. Use the id of your destination on the page
}, 'slow');
});
这是我正在使用的翻转代码:
document.getElementById( 'back' ).addEventListener( 'click', function( event ) {
event.preventDefault();
document.getElementById( 'side-2' ).className = 'flip flip-side-1';
document.getElementById( 'side-1' ).className = 'flip flip-side-2';
}, false );
document.getElementById( 'front' ).addEventListener( 'click', function( event ) {
event.preventDefault();
document.getElementById( 'side-2' ).className = 'flip';
document.getElementById( 'side-1' ).className = 'flip';
}, false );
我已尝试使用 scrollTop 在 SO 和 elsewhere 上找到的各种代码,但我似乎无法拨入。
【问题讨论】: