[jquery] 화면 center에 오도록 하는 function
2021. 1. 30.
jQuery. 또는
$. 둘다 가능
jQuery.fn.center = function () {
this.css("position","absolute");
this.css("top", Math.max(0, (($(window).height() - $(this).outerHeight()) / 2) +
$(window).scrollTop()) + "px");
this.css("left", Math.max(0, (($(window).width() - $(this).outerWidth()) / 2) +
$(window).scrollLeft()) + "px");
return this;
}
-호출시
$(아이디 또는 클래스).center();
'JS_CSS' 카테고리의 다른 글
pc,모바일 구분 - 안드로이드, iOS 구분하기 (0) | 2021.02.17 |
---|---|
[JQuery] map 으로 join하는 함수 - 일렬화 (0) | 2021.02.17 |
[jBox] Options (0) | 2021.02.01 |
(box_img) 가로세로 길이 상관없이 부모박스에 이미지 사이즈 조절 (0) | 2021.01.31 |
[jquery]Ajax FormData로 파일 저장하기.(IE10이하 버젼 제외) (0) | 2021.01.31 |