浮动元素和绝对定位元素是同级的话,绝对定位元素就会消失,所以咱们只要让他们两个不处于同级就可以避免这个BUG
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.box{
width: 200px;
height: 200px;
border:1px solid black;
position: relative;
}
.item{
width: 150px;
height: 150px;
background-color: red;
float: left;
margin-left: 50px;
*display: inline;
}
.box span{
width: 50px;
height: 50px;
background-color: yellow;
position: absolute;
right: -10px;
top: -10px;
}
</style>
</head>
<body>
<div class="box">
<div class="item"></div>
<p><!-- 这里没有P标签就会触发-->
<span></span>
</p>
</div>
</body>
</html>