JS弹出层单纯的绝对定位居中示例代码_javascript技巧
来源:动视网
责编:小采
时间:2020-11-27 21:19:52
JS弹出层单纯的绝对定位居中示例代码_javascript技巧
JS弹出层单纯的绝对定位居中示例代码_javascript技巧: 代码如下: function doThis() { var a = document.getElementById(addYear); a.style.left=(document.body.clientWidth/2-a.clientWidth/2)+px; a.style.top=(document.body.scrollTop+docum
导读JS弹出层单纯的绝对定位居中示例代码_javascript技巧: 代码如下: function doThis() { var a = document.getElementById(addYear); a.style.left=(document.body.clientWidth/2-a.clientWidth/2)+px; a.style.top=(document.body.scrollTop+docum

代码如下:
function doThis()
{
var a = document.getElementById("addYear");
a.style.left=(document.body.clientWidth/2-a.clientWidth/2)+"px";
a.style.top=(document.body.scrollTop+document.body.clientHeight/2-a.clientHeight/2)+"px";
}
JS弹出层单纯的绝对定位居中示例代码_javascript技巧
JS弹出层单纯的绝对定位居中示例代码_javascript技巧: 代码如下: function doThis() { var a = document.getElementById(addYear); a.style.left=(document.body.clientWidth/2-a.clientWidth/2)+px; a.style.top=(document.body.scrollTop+docum