I am trying to center a div element. It seems in my code that all is right but the element is not being centered properly Where did I wrong? If i try to center it by using flexbox then it is centered properly. Where is the wrong of positioning property?
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
.container {
  width: 200px;
  height: 39px;
  border: 1px solid red;
  position: relative;
}
.cntr {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background-color: blue;
  width: 35px;
  height: 35px;
}<div class='container'>
  <div class='cntr'>
  </div>
</div> 
     
    