css z-index 失效 不好用 的解决方法
如果两个div层 没有上下区分可以添加 position: relative;试一下
下面介绍设置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>
</html>
来源://作者:/更新时间:2012-12-03
顶
踩
相关文章:
- 高端大气简约的表格式样实例_蓝色紫色table css 样式_
- html颜色代码表大全_HTML背景颜色代码_html字体颜色表
- resize 调节元素尺寸大小【CSS3.0参考手册】
- text-overflow 文本溢出显示省略标记【CSS3.0参考手册
- text-shadow 文字阴影及模糊效果【CSS3.0参考手册】
- Multiple backgrounds 多重背景图象【CSS3.0参考手册
- background-size 设置背景图片的大小【CSS3.0参考手
- background-clip 指定区域向外裁剪背景【CSS3.0参考手
- background-origin 指定区域显示背景【CSS3.0参考手册
- box-shadow[css3.0参考手册]




![box-shadow[css3.0参考手册]](/d/file/webkaifa/CSS/2012-11-09/67f47fb6ec0346889fbde7fd4dab0eef.jpg)