两种方法都能够实现:
1.
div { height:80%; /*一定要设置高度*/
overflow:hidden;/*建议设置*/ margin: auto; position: absolute; top: 0; left: 0; bottom: 0; right: 0; }
2.
div{ position: absolute; 80%; height: 60%; padding: 2%; top: 50%; left: 50%; margin-left: -41%; /* (width + padding)/2 */ margin-top: -31%; /* (height + padding)/2 */ }