<!-- flex很强大,但是兼容性不是非常好,个人倒是比较喜欢flex -->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<!-- 同上,兼容性不是很好 -->
<title>水平居中:使用flex和justify-content</title>
<style type="text/css">
.parent{
display: flex;
justify-content: center;
}
.son{
background-color: #0000FF;
}
</style>
</head>
<body>
<div class="parent">
<div class="son">
测试
</div>
</div>
</body>
</html>