css设置模态框如何显示在最上层
来源:网络收集 点击: 时间:2024-05-22初始代码如下:
html
head
title/title
/head
style type=text/css
.red{
width:100px;
height: 100px;
background: red;
position: absolute;
}
.yellow{
width: 200px;
height: 100px;
background: yellow;
position: absolute;
}
/style
body
div class=red/div
div class=yellow/div
/body
/html
可以看出橙色的div明显在红色的div上面,现在使用z-index属性控制红色div在橙色div上面。

代码如下:
html
head
title/title
/head
style type=text/css
.red{
width:100px;
height: 100px;
background: red;
position: absolute;
z-index: 11;
}
.yellow{
width: 200px;
height: 100px;
background: yellow;
position: absolute;
}
/style
body
div class=red/div
div class=yellow/div
/body
/html
效果如下图:

版权声明:
1、本文系转载,版权归原作者所有,旨在传递信息,不代表看本站的观点和立场。
2、本站仅提供信息发布平台,不承担相关法律责任。
3、若侵犯您的版权或隐私,请联系本站管理员删除。
4、文章链接:http://www.1haoku.cn/art_825139.html