IE5、6下絕對定位元素和浮動元素並列,絕對定位元素消失不見解決方案
阿新 • • 發佈:2019-01-27
浮動元素和絕對定位元素是同級的話,絕對定位元素就會消失,所以咱們只要讓他們兩個不處於同級就可以避免這個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>