-2

How can I disable margin collapse and get 200px margin without changing the HTML?

code:

<style>

div{
  font-size: 100px;
  border: 10px solid black;
  padding: 20px;
  margin: 100px;

</style>

<body>

  <div>AAAA</div>

  <div>AAAA</div>

</body>

Thanks, :D.

LiavReuven
  • 109
  • 3
  • Hi, what do you mean by margin collapse? Could you explain a little more what is it that you want to do? – vitomadio Aug 25 '18 at 10:16

1 Answers1

-1

Try adding a padding of 0.1px to the body tag, or any parent tag that will include these 2 divs.

This old trick used to disable collision for most cases.

You may want to see an explanation and other solutions here: How to disable margin-collapsing?

Ahmed Hammad
  • 2,798
  • 4
  • 18
  • 35