css样式 div垂直水平居中对齐

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>菜鸟教程(runoob.com)</title> 
<style> 
div
{
    width:100px;
    height:100px;
    border:1px solid black;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
    /* Rotate div */
}
</style>
</head>
<body>

<div>Hello</div>

</body>
</html>

相关推荐