> 웹 프론트엔드 > JS 튜토리얼 > 페이지 높이와 스크롤 막대 위치를 가져오는 자바스크립트 코드_javascript 기술

페이지 높이와 스크롤 막대 위치를 가져오는 자바스크립트 코드_javascript 기술

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
풀어 주다: 2016-05-16 18:27:59
원래의
1036명이 탐색했습니다.
复제대码 代码如下:

var Viewport={
top : function(){
return window.pageYOffset
|| document.documentElement && document.documentElement.scrollTop
|| document.body.scrollTop;
},
height : function(){
return window.innerHeight
|| document.documentElement && document.documentElement.clientHeight
|| document.body.clientHeight;
},
left : function(){
return window.pageXOffset
|| document.documentElement && document.documentElement.scrollLeft
|| document.body.scrollLeft;
},
width : function(){
return window.innerWidth
|| document.documentElement && document.documentElement.clientWidth
|| document.body.clientWidth;
},
right : function(){
return Viewport.left() Viewport.width();
},
bottom : function(){
return Viewport.top() Viewport.height();
}
};


居中:
复代码 代码如下:

style.position="절대";
style.left=50%;
style.top=Viewport.Top() Viewport.Height()/2 "px";
관련 라벨:
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿