Align vertically using CSS 3
问题 With CSS 3, are there any way to vertically align an block element? Do you have an example? Thank you. 回答1: Was looking at this problem recently, and tried: HTML: <body> <div id="my-div"></div> </body> CSS: #my-div { position: absolute; height: 100px; width: 100px; left: 50%; top: 50%; background: red; transform: translate(-50%, -50%); -webkit-transform: translate(-50%, -50%); -moz-transform: translate(-50%, -50%); -ms-transform: translate(-50%, -50%); } Here's the Fiddle: http://jsfiddle.net