<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>定寬塊狀元素水平居中</title>
<style>
div{
? ? width:600px;
? ? height:300px;
? ? border:1px solid red;
? ? margin:20px;
}
.txtCenter{
text-align:center;
}
.imgCenter{
? ? text-align:center;
? ? display:table-cell;
? ? vertical-align:middle;
}
</style>
</head>
<body>
<div class="txtCenter">我想要在父容器中水平居中顯示泳挥。</div>
<!--下面是任務(wù)部分-->
<div class="imgCenter"><img src="http://img1.sycdn.imooc.com/52da54ed0001ecfa04120172.jpg" /></div>
</body>
</html>