<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>定宽块状元素水平居中</title>
<style>
div{
border:1px solid red;
margin:20px;
}
.txtCenter{
text-align:center;
}
.imgCenter{text-align:center;}
</style>
</head>
<body>
<div class="txtCenter">我想要在父容器中水平居中显示。</div>
<!--下面是任务部分-->
<div class="imgCenter"><img width=100% height=100% src="http://img.mukewang.com/52da54ed0001ecfa04120172.jpg" /></div>
</body>
</html>
<style>
........
img {
width:100%;
height:100%;
}
</style>
把img选择 写在style标签里面
100%加引号也行
<img style="width:100%;height:100%">