JSFiddle - React, Tailwind, and code Playground

by johntrepreneur

HTML

<br>
Negative margins don't hold position of elements after it and alter the flow of everything following.
<br>
<br>
<div class="div1">
  <div class="div2">test</div>
  <div class="div3">stuff</div>
</div>

<br>
Relative positioning with negative top holds the position of elements after it and alter the flow of everything following.
<br>
<br>
<div class="div1">
  <div class="div5">test</div>
  <div class="div3">stuff</div>
</div>

CSS

.div1 {
  height: 100px;
  width: 200px;
  background-color: pink;
  border: 1px solid red;
}
.div2 {
  border: 1px solid green;
  margin-top: -10px;
}
.div5 {
  border: 1px solid green;
  position: relative;
  top: -10px;
}

.div3 {
  border: 1px solid blue;
}