Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/438.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 临时覆盖页边距_Javascript_Css - Fatal编程技术网

Javascript 临时覆盖页边距

Javascript 临时覆盖页边距,javascript,css,Javascript,Css,如果我将页面边距设置为5或10像素,是否仍有覆盖整个页面宽度的内容 如果我的页面边距设置为10,并且我想覆盖页面宽度,我将其设置为零,它仍然有10。。。它将其用作最大保证金的默认值 样本 在主体内部使用div创建边距-例如 <body> <div id="main-content" style="margin: 10px"> ... </div> <div id="div-all-over-the-page" style="posit

如果我将页面边距设置为5或10像素,是否仍有覆盖整个页面宽度的内容

如果我的页面边距设置为10,并且我想覆盖页面宽度,我将其设置为零,它仍然有10。。。它将其用作最大保证金的默认值

样本


在主体内部使用div创建边距-例如

<body>
  <div id="main-content" style="margin: 10px">
    ...
  </div>
  <div id="div-all-over-the-page" style="position: absolute; width: 100%; height: 100%; top: 0px; left: 0px">
     ...
  </div>
</body>

如何从javascript动态地覆盖它?这会动态地更改主体,但foo-bar仍然是主体设置为的内容。这只是一个完整的示例-不想在链接上设置bothlook-js解决方案不适合这种情况-将需要margin的元素打包到div中或使用类进行设置
document.body.style.margin = '20px'; // for body
document.getElementById( 'foo-bar' ).style.margin = '20px'; // for specific element