<!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>
<style>
* {
padding:0;
margin: 0;
border: none;
}
.wrapper {
width: 500px;
overflow: hidden;
background-color: grey;
}
.cell {
display: inline-block;
width: 50%;
}
.left {
background-color: red;
}
.right{
background-color: blue;
}
</style>
</head>
<body>
<div class="wrapper">
<div class="cell left">left</div>
<div class="cell right">right</div>
</div>
</body>
</html>
直觉认为红块和蓝块应该是在同一行,然而并不是
设置float:left
属性后两块并排了,width:49%
也并排了,width:250px
还是两排。造成这个问题的关键点在哪?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…