下拉到底部自动显示菜单是一种常用的CSS效果,可以让网页更加美观和用户友好。实现此效果,需要用到一些CSS技巧和简单的JavaScript代码。 首先,我们可以使用CSS的position属性来实现下
p { position: absolute; width: 200px; height: 200px; bottom: 0; }
window.addEventListener('scroll', function() { var scrollHeight = document.documentElement.scrollHeight; var currentHeight = window.innerHeight + window.pageYOffset; var menu = document.querySelector('p'); <br> if (scrollHeight == currentHeight) { menu.style.visibility = 'visible'; } else { menu.style.visibility = 'hidden'; } });
粉丝
0
关注
0
收藏
0