div居中
怎么让div中的div居中
怎么让div中的div居中
2017-11-02
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>div包含div居中</title>
<style type="text/css">
.div1{
width:200px;
height:200px;
border:1px red solid;
}
.div2{
border:2px dashed red;
width:50px;
height:20px;
margin-top:91px;<!--(200-20+2)/2-->
margin-bottom:91px;
margin-left:73px;<!--(200-50+2)/2-->
}
</style>
</head>
<body>
<div class="div1"><div class="div2">居中</div></div>
</body>
</html>
举报