Javascript 临时覆盖页边距
如果我将页面边距设置为5或10像素,是否仍有覆盖整个页面宽度的内容 如果我的页面边距设置为10,并且我想覆盖页面宽度,我将其设置为零,它仍然有10。。。它将其用作最大保证金的默认值 样本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
在主体内部使用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