问题描述:

This question already has an answer here:

  • Element will not stay centered, especially when re-sizing screen

    2 answers

网友答案:

First of all you need to understand the position relative. as per w3school "An element with position: relative; is positioned relative to its normal position." so percentages in top,left etc will not work. if you give it in px ie top:10px; it will take position from its current location. and for your question about translateY(); As per w3school "The translate() method moves an element from its current position" TraslateY() moves the the element vertically down, and negative value will move it opposite to top. for further reading you can check this link http://www.w3schools.com/css/css3_2dtransforms.asp

相关阅读:
Top