asp.net - 未应用 z 索引属性

标签 asp.net html css

我正在使用以下 html 标记和 css 代码来设计我的着陆页。

HTML

<!DOCTYPE html>

<html>
<head runat="server">
    <title></title>
    <link href="Styles/Site.css" rel="stylesheet" type="text/css" />
</head>
<body style="background:transparent;">
<div id="divContainer"></div>
    <form id="form1" runat="server">
    <div id="topDiv"></div>

    <div id="divMain">
    <aside><div id="logo">
    <img id="imgLogo" src="Images/minerva.jpg" />
    </div></aside> 
    <aside>
        <div id="divContact"></div>
    </aside>
    </div>
    <footer>
    </footer>
    </form>
</body>
</html>

CSS

#topDiv {
    box-shadow: 0px 10px 20px #888888;
    background-color: #113871;
    width: 100%;
    height: 40px;
}
#logo { }
#imgLogo {
    width: 400px;
    height: 200px;
    margin-top: 20px;
    float: left;
}
#divContact {
    width: 300px;
    height: 400px;
    background-color: White;
    opacity: 0.5em;
    float: right;
    z-index: 9999;
    margin-right: 50px;
    margin-top: 149px;
    border-radius: 5px;
    -moz-border-radius: 5px;
    -webkit-border-radius: 5px;
    box-shadow: 0 0 .5em .25em Gray;
}
footer {
    width: 100%;
    height: 150px;
    background-color: #113871;
    display: block;
    float: left;
    margin-top: -100px;
    z-index: -1;
}

我为 #divContact 指定了 z 索引值 9999,为页脚标签指定了 -1。我的问题是我没有得到想要的东西,即将 divContact 放在前面。任何人都可以看看。

最佳答案

z-index 仅适用于定位 元素:

/* This does not work */
.foo {
    z-index: 10;
}

/* This works */
.bar {
    position: relative;
    z-index:  10;
}

来源:http://www.w3.org/TR/CSS2/visuren.html#z-index

关于asp.net - 未应用 z 索引属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10807367/

相关文章:

javascript - Internet Explorer 7 的 CSS 翻转问题

c# - 如何将枚举值设置为 Web 用户控件的自定义属性?

asp.net - IIS Express (WebMatrix) 对外部连接开放

asp.net - ASP.NET客户端到服务器的通信

javascript - 绘制滚动图的最佳方法

javascript根据星期几更改元素类

javascript - ajaxcontroltoolkit 的 Ajax CDN 支持

html - 使 div 高度为 100%

javascript - 如何从输入更改 src?

javascript - 鼠标悬停时在图像元素上放置 jquery 动画