flexable하게 가운데 정렬
ie10 이상 일 경우
position:fixed;
left:50%; top:50%;
transform: translate(-50%, -50%);
margin:auto;
ie10 이하 일 경우
가로의 경우
media query를 사용하여, 넓은 화면에선 고정(px)로 사용하고, 좁은 화면에서 동적(%)으로 설정할 수 있다.
case 1 : width를 %로 설정한 경우
// width가 %일 경우 남은 여백을 양쪽 마진으로 설정한다. ※ auto 적용 불가
width:80%;
margin:0 10%;
case 2 : width를 px로 설정한 경우
// left를 50%로 설정하고, margin-left를 팝업상자(modal) 넓이/2만큼 뺀다.
@media (min-width:500px) {
left:50%;
width:400px;
margin-left:-200px;
}
세로의 경우
top:50%;
case 1 : height이 고정(px)인 경우
// margin-top을 팝업상자(modal) 높이/2만큼 뺀다.
height:200px;
margin-top:-100px;
case 2 : height가 동적일 경우
javascrip에서 팝업상자(modal)의 높이를 계산하여 높이/2만큼 빼도록 설정한다.
$(documnet).ready(function(){
$(".modal").css("margin-top","-" + ($(".modal").outerHeight())/2 + "px");
return this;
});