我有一些代码如下,我认为我的分层导致呈现的链接不可点击。这个例子中的一些我已经从外部 CSS 类转换为样式,以便于将其编写为一个小用例。这目前正在现代浏览器(最新稳定的 FF 和 Chrome)上进行测试。
<body>
<!-- whole container needs to be at z-index of -1 -->
<div id="container">
<div class="corner" id="backgroundTopLeft"></div>
<div class="corner" id="backgroundTopRight"></div>
<div class="corner" id="backgroundBottomLeft"></div>
<div class="corner" id="backgroundBottomRight"></div>
<!-- whole container needs to be at z-index of 1 -->
<div id="container2">
<div id="headerSection"><img src="images/jClarity_logo.png" alt="logo" /></div>
<div id="navigationSection">
<a class="selected" href="#">Introduction</a><span class="menuDivider">|</span><a href="about.html">About</a>
</div>
</div>
</div>
</body>
和 CSS
@charset "utf-8";
/* Default margin, padding and font-family */
*
{
font-family: Arial;
margin: 0px;
padding: 0px;
}
/* All images should have no borders by default */
img
{
border: none;
}
/* Global styling for links, uses black as the color */
a
{
color: #000000;
text-decoration: none;
}
a.selected
{
font-weight: bold;
}
a:hover
{
color:#FF00FF;
}
#container
{
position: relative;
z-index: -1;
height: 100%;
}
.corner
{
position: absolute;
height: 100px;
width: 100px;
background-color: #172944;
z-index: -1;
}
#backgroundTopLeft
{
top: 0px;
left: 0px;
}
#backgroundTopRight
{
top: 0px;
right: 0px;
}
#backgroundBottomLeft
{
bottom: 0px;
left: 0px;
}
#backgroundBottomRight
{
bottom: 0px;
right: 0px;
}
#container2
{
position: relative;
width: 100%;
height: 100%;
z-index: 1;
opacity: 0.8;
filter:alpha(opacity=80);
background-image:url('../images/groovepaper.png');
}
/* The headerSection div, designed to fit in a centered logo */
#headerSection
{
margin-left: auto;
margin-right: auto;
padding-bottom: 70px;
padding-top: 54px;
height: 70px;
width: 250px;
}
/* The navigationSection div, designed to fit in the menu */
#navigationSection
{
padding-bottom: 15px;
margin-left: auto;
margin-right: auto;
width: 600px;
text-align: right;
}
.menuDivider
{
color: #666666;
padding-left: 5px;
padding-right: 5px;
}
一切看起来都很好(应用了许多其他纯颜色/字体大小的样式),但是 foobar.html 不可点击。
我很确定我在分层方面做错了什么,但我认为使用 z-indices 可以解决我的问题。