猿问

怎样手动滑动div

我的body里有两个div,默认第一个div, height站满屏,有一个点击事件,点击事件中用什么方法能够滑动到屏幕的底部啊

慕莱坞森
浏览 540回答 1
1回答

Qyouu

$("#div").animate({height:'0'});<style>body{margin:&nbsp;0;&nbsp;padding:&nbsp;0}#content1{&nbsp;&nbsp;&nbsp;&nbsp;height:&nbsp;100%;&nbsp;&nbsp;&nbsp;&nbsp;background-color:&nbsp;#00a0c6;&nbsp;&nbsp;&nbsp;&nbsp;width:&nbsp;100%; }#content2{&nbsp;&nbsp;&nbsp;&nbsp;width:&nbsp;100px;&nbsp;&nbsp;&nbsp;&nbsp;height:&nbsp;100px;&nbsp;&nbsp;&nbsp;&nbsp;background-color:&nbsp;white;&nbsp;&nbsp;&nbsp;&nbsp;z-index:&nbsp;100;&nbsp;&nbsp;&nbsp;&nbsp;float:&nbsp;left;&nbsp;&nbsp;&nbsp;&nbsp; position:&nbsp;fixed;&nbsp;&nbsp;&nbsp;&nbsp;top:&nbsp;0; }</style><script>$(function&nbsp;()&nbsp;{ &nbsp;$('body').height(window.screen.height); &nbsp;$('body').width(window.screen.width); })</script><body><div id="content2"></div><div id="content1"></div><script>$('#content1').click(function&nbsp;()&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;$('#content2').animate({top:'85%'}); })</script>
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答