#parent {
  position: fixed;
  width: 600px;
  height: 300px;
  background: red;
}
#child {
  position: relative;
  width: 200px;
  margin-bottom: 10px;
  margin-top: 10px;
  height: auto;
  background: blue;
}<div id="parent">
  <div id="child"></div>
</div>I want to have the child to have the height of the parent minus the margins. Why is the height 0px?
 
     
    