1 方法:
①设置div1的margin-top的值为 (div的height-div1的height)/2
②设置div1的display值为 inline-block
2 代码
<html><head>
<title></title>
<style type="text/css">
div {
width: 700px
height: 100px
background-color: #93C
}
#div1 {
width: 700px
height: 40px
background-color: #06F
margin-top: 30px
display: inline-block
}
</style>
</head>
<body>
<div>
<div id="div1">div1</div>
</div>
</body>
</html>
3 显示效果如下