<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<style>
.outer{
width:500px;
height: 500px;
background: green;
}
.outer>div{
display: inline-block;
}
.inner1{
width:48%;
height:48%;
margin: 0 1%;
background: powderblue;
}
.inner2{
width: 48%;
height: 48%;
margin: 0 1%;
background: blue;
}
</style>
<body>
<div class="outer">
<div class="inner1"></div>
<div class="inner2"></div>
</div>
</body>
</html>
这样加起来不正好每个百分之50么,感觉应该在一行才对啊
因为用的属性inline-block。而两个DIV之间,存在空格(换行)。所以就超过了100%。删掉换行,就在一行了!