document.body.addEventListener("scroll", function () {
// 真实内容的高度
var pageHeight = Math.max(document.body.scrollHeight, document.body.offsetHeight);
console.log(pageHeight, '真实内容的高度',document.body.scrollHeight,document.body.offsetHeight);
// 视窗的高度
var viewportHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight || 0;
console.log(viewportHeight,'视窗的高度');
// 隐藏的高度
var scrollHeight = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
console.log(scrollHeight,'隐藏的高度');
//判断加载视频
if (pageHeight - viewportHeight - scrollHeight <= 0) {
//事件
console.log('请求数据','逻辑操作');
}
});
水平居中未知父元素高度
{
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%,-50%)
}
{ position: absolute;
left:50%;
top:50%;
-webkit-transform:translate(-50%,-50%);
-moz-transform:translate(-50%,-50%);
-ms-transform:translate(-50%,-50%);
-o-transform:translate(-50%,-50%);
transform:translate(-50%,-50%);
}