設置z-index時必須要固定位置,這樣設置它的值時才能奏效(例如 position:absolute;)
下面是示例代碼,在ff3.5.5和ie5.5~ie8.0RC1中通過,大家可以嘗試著不固定其位置試試。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<style type="text/css">
#king_of_diamonds {
position: relative;
background-color:gray;
width:30px; height:30px;
left: 145px;
top: 145px;
}
#ace_of_diamonds {
position:relative;
background-color:blue;
width:300px; height:300px;
left: 160px;
top: 130px;
z-index: 1;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div id="king_of_diamonds">
a
</div>
<div id="ace_of_diamonds">
b
</div>
</form>
</body>
如對本文有疑問,請?zhí)峤坏浇涣髡搲?,廣大熱心網(wǎng)友會為你解答??! 點擊進入論壇