由于某种原因无法减少保证金

Cant reduce margin for some reason

我有一个 div 但由于某些原因我无法减少它的边距。

HTML

<div class="activebombgame">

</div>

CSS

.activebombgame{
  height: 82vh;
  width: 5vw;
  background: black;
  margin: 0;
 }

This is from google chrome developer tools(blue = div, orange = margin)

整个源代码:https://www.hastebin.com/tapodoyuke.xml

您的代码运行良好,请参阅 fiddle here。可能周围的标签限制了调整大小。尝试将“.activebomb”带到外面

<div class="sorrounding"> 

</div>

<div class="activebombgame">

</div>

这听起来像是您的 body 保证金。默认情况下,许多页面都有一组。有关示例,请参见下面的测试。当你第一次 运行 它时,正文有一个默认边距。单击该按钮将删除它并使您的 div 与页面边缘对齐。

function change() {
    document.body.style.margin = "0px";
}
.activebombgame{
  height: 82vh;
  width: 5vw;
  background: black;
  margin: 0px;
 }
 
 body {
   background-color: lightgray;
 }
 
 button {
   position: fixed;
   left: 40%;
   top: 20%;
 }
<div class="activebombgame">

</div>

<button onclick='change();'>Remove Body Margin</button>

@Nisarg Shah, 您在最后添加了一个额外的关闭 div,这就是您的 css 无法正常工作的原因。删除额外的关闭 div 和 运行 它。