【发布时间】:2011-01-09 03:16:56
【问题描述】:
我是一名程序员,正在学习 Web 开发方面的新技术。如果您可以查看下面的链接,我遇到了问题。 http://bailesslaw.com/Bailess_003/bailesHeader/header.html 我做的这个例子不是固定的,它需要固定,这变得越来越困难。
这里看起来不错,但是当我将这些图层放在主网站 index.html 上时,将此代码作为标题放置,横幅会移动到文档位置 0,0 。我需要固定这些框,居中页面,如果不弄乱图层顺序和内容,我无法让它们做到这一点。
Layer1-旋转图片,js导致旋转 Layer2-蓝色三角形与背景效果重叠第 1 层, 第 3 层 - 是具有高 z-index 的静态图像
下面我包含了一些代码,重要的部分需要3个重叠层在宽度和高度上完全匹配,除了它必须固定在中心780px宽。
代码:
<style rel="stylesheet" type="text/css">
div#layer1 {
border: 1px solid #000;
height: 200px;
left: 0px;
position: fixed;
top: 0px;
width: 780px;
z-index: 1;
}
div#layer2 {
border: 1px solid #000;
height: 200px;
left: 0px;
position: absolute;
top: 0px;
width: 780px;
z-index: 2;
}
div#layer3 {
border: 1px solid #000000;
height: 200px;
left: 0px;
position: absolute;
top: 0px;
width: 780px;
z-index: 3;
}
</style>
</head>
<body class="oneColFixCtr">
<div id="container">
<div id="mainContent">
<div id="layer1">
</div>
<div id="layer2">
<div class="slideshow">
<span id="rotating1">
<p class="rotating">
</p>
</span>
<span id="rotating2">
<p class="rotating">
</p>
</span>
<span id="rotating3">
<p class="rotating">
</p>
</span>
<span id="rotating4">
<p class="rotating">
</p>
</span>
</div>
</div>
<div id="layer3">
<table width="385" border="0">
<tr>
<th width="81" scope="col">
</th>
<th width="278" scope="col">
</th>
<th width="12" scope="col">
</th>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
</table>
</div>
</div>
<!-- end #container -->
</div>
</body>
</body>
</html>
CSS:
@charset "utf-8";
CSS code:
#rotating1 {
height: 200px;
width: 780px;
}
#rotating2 {
height: 200px;
width: 780px;
}
#rotating3 {
height: 200px;
width: 780px;
}
#main {
background-repeat: no-repeat;
height: 200px;
width: 780px;
z-index: 100;
}
#test {
width: 780px;
z-index: 2;
}
#indexContent {
background-color: #12204d;
background-repeat: no-repeat;
height: 200px;
width: 780px;
z-index: 1;
}
#indexContent p {
padding: .5em 2em .5em 2em;
text-align: justify;
text-indent: 2em;
}
.rotating {
float: right;
margin-top: 227px;
text-indent: 0px !important;
}
.clearfix:after {
clear: both;
content: " ";
display: block;
font-size: 0;
height: 0;
visibility: hidden;
}
.clearfix {
display: inline-block;
}
* html .clearfix {
height: 1%;
}
.clearfix {
display: block;
}
【问题讨论】:
-
请设置一个 jsfiddle @jsfiddle.net