方法二按字面意思先用display:inline后用text-alinh:center为何不能使div居中,还是要要引入ul列表才能用呢?
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>不定宽块状元素水平居中</title>
<style>
.container{display:inline;}
.container{text-align:center;}
</style>
</head>
<body>
<div class="container">你好,我要居中</div>
</body>
</html>