Have a look at this: https://codepen.io/J-tt/pen/ReJRLQ
Centering in CSS is notorious, if you want some different methods have a look at http://howtocenterincss.com/
Flex-box is currently the best way to center, and has very wide browser support.
Edit: I believe your centering method isn't working due to missing semicolons after 'top' and 'left'