달력

52024  이전 다음

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

'layer center'에 해당되는 글 1건

  1. 2017.01.26 JQuery를 통해서 레이어 팝업 항상 화면 가운데에 띄우기
반응형

<script type="text/javascript">

...

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;
}

...

 

showPopup = function() {

$("#popLayer").show();

$("#popLayer").center();

}

 

</script>

 

<body>

...

 

<a href="javascript:;" onclick="javascript:showPopup()">팝업띄우기</a>

 

...

</body>

 

<div id="popLayer" style="display:none;">

<div>팝업 레이어입니다.</div>

<div>

 코드 출처 : http://stackoverflow.com/questions/210717/using-jquery-to-center-a-div-on-the-screen

출처 : http://ooz.co.kr/78

반응형
Posted by 친절한 웬디양~ㅎㅎ
|