Home  >  Article  >  Web Front-end  >  Simple absolute positioning and centering sample code for JS pop-up layer_javascript skills

Simple absolute positioning and centering sample code for JS pop-up layer_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:59:301748browse
复制代码 代码如下:

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";
}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn