The Height of parent and child will be given at run time, I have tried vertical-align but it didn't work, margin/top property won't be correct because height is dynamic. Please provide proper way to fix this.
Expected: Child should be center of parent. Width should remain same
Update: Solution of @xmastertje is working, but if i change my child height it breaks. This question is part of big problem so I can't use calc here. In real time I have nested elements each should center of its parent.
:root {
  --parent-height: 500px;
  --child-height: 200px;
}
html,
body {
  width: 100%;
  height: 100%;
}
.parent {
  height: var(--parent-height);
  background-color: #bada55;
  position: relative;
}
.child {
  height: var(--child-height);
  background-color: goldenrod;
}<div class="parent">
  Parent Has 500px Height
  <div class="child">
    child has 200px height
  </div>
</div> 
     
     
     
     
     
     
    