Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在document.getElementById()上添加样式_Javascript_Css - Fatal编程技术网

Javascript 如何在document.getElementById()上添加样式

Javascript 如何在document.getElementById()上添加样式,javascript,css,Javascript,Css,我有一个加载程序图像显示在我的iFrame的左角,但是,我试图显示在中间。请告知如何在以下代码中添加样式: var ShowLoader = function() { document.getElementById("mainIframe").style.display = "none"; document.getElementById("documentIframe").src = "http://localhost:63902/images/loading.gif"; }

我有一个加载程序图像显示在我的iFrame的左角,但是,我试图显示在中间。请告知如何在以下代码中添加样式:

var ShowLoader = function() {
    document.getElementById("mainIframe").style.display = "none";
    document.getElementById("documentIframe").src = "http://localhost:63902/images/loading.gif";
}

使用下面的代码居中对齐

document.getElementById("documentIframe").style.textAlign = "center";
document.getElementById("documentIframe").style.margin = "0px auto";

使用
document.getElementById(“mainIframe”).style有什么问题?
问题、说明和代码不匹配
。style.textAlign=“center”
可能?