This article mainly introduces pure html+css+javascript to realize floor-jumping page layout. Friends who need it can refer to it. I hope it can help everyone.
Implementation effect demonstration:
Implementation code and comments:
myScroll .js
function scroll() { // 开始封装自己的scrollTop if(window.pageYOffset !== undefined) { // ie9+ 高版本浏览器 // 因为 window.pageYOffset 默认的是0,所以需要判断 return { left: window.pageXOffset, top: window.pageYOffset } } else if(document.compatMode === "CSS1Compat") { // 标准浏览器,来判断有没有声明DTD return { left: document.documentElement.scrollLeft, top: document.documentElement.scrollTop } } return { // 未声明 DTD left: document.body.scrollLeft, top: document.body.scrollTop } }
Related recommendations:
Understanding of page layout in html
Several methods of adjusting page layout
6 div+css page layout introductory tutorial and summary of usage examples
The above is the detailed content of HTML, css, and javascript realize floor-hopping page layout. For more information, please follow other related articles on the PHP Chinese website!