Center a popup window on screen?

前端 未结 18 1119
一整个雨季
一整个雨季 2020-11-22 16:51

How can we center a popup window opened via javascript window.open function on the center of screen variable to the currently selected screen resolution ?

18条回答
  •  星月不相逢
    2020-11-22 17:18

    You can use css to do it, just give the following properties to the element to be placed in the center of the popup

    element{
    
    position:fixed;
    left: 50%;
    top: 50%;
    -ms-transform: translate(-50%,-50%);
    -moz-transform:translate(-50%,-50%);
    -webkit-transform: translate(-50%,-50%);
     transform: translate(-50%,-50%);
    
    }
    

提交回复
热议问题