CSS / HTML如何不重叠固定标头

时间:2012-12-10 16:30:57

标签: html css

我有一个像twitter / facebook一样的标题,固定的和主要的内容。当我向下滚动到最后一行时,内容div与标题重叠。我怎么能避免这个?

这是我页面的截图: enter image description here

这是我html的结构:

<body>

<div>
<?php include("initcontrols/header.php"); echo $plHeader;?>   
</div>


<div id="mainform">
<noscript>It seems your browser doesn't support Javascript.<br /></noscript>

<!-- Apply blue theme as default for all tiles -->
<div id="tiles" class="blue">
<!-- Sliding Tile that shows 100% of the back tile every 3 seconds -->
<div class="live-tile" data-stops="100%" data-speed="750" data-delay="3000">
    <span class="tile-title">slide tile (figure 2a)</span>
    <div><img src="images/say.jpg" width="180" height="180" alt="1" /></div>
    <div><img src="images/sayako.jpg" width="180" height="180" alt="2" /></div>
</div>

    <!-- Red Flip Tile that flips every 4 seconds -->
<div class="red live-tile" data-mode="flip" data-delay="4000">
    <div>
        <img src="images/home.png" alt="3" />
        <a class="tile-title">flip tile front (figure 2b)</a>
    </div>
    <div>
        <img src="images/message.png" alt="4" />
        <a class="tile-title">flip tile back (figure 2b)</a>
        </div>
</div>


<script type="text/javascript">
// apply regular slide universally unless .exclude class is applied 
// NOTE: The default options for each liveTile are being pulled from the 'data-' attributes
$(".live-tile, .flip-list").not(".exclude").liveTile();
</script>

</div>

我的css:

div#header{
padding-left:15px;
overflow:hidden;
position: fixed;
margin:0px;
top:0px;
left:0px;
display: block;
width: 100%;
height: 90px;
-moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
background:#333333;
background: -moz-linear-gradient(center top , #736F6E, #111111) repeat scroll 0 0 transparent;
}
div#header-title{
color: #FFF;
float: left;
display:inline-block;
}
div#header h2{
margin: 0 0 0 3px;
z-index:12;
}
div#header h1{
margin-top:0;
margin-bottom:0;
}

#mainform{
width:960px;
background: #F0F0F0;
border: 1px solid #CCC;
height: 2000px;
margin: 100px auto;

}

和我的实时瓷砖外观: http://pastebin.com/cpBXYVRu 我使用了http://www.drewgreenwell.com/projects/metrojs#applicationBar的模板:

2 个答案:

答案 0 :(得分:5)

您可以调整元素的z-index以将其定位在另一个元素后面。在这种情况下,您可能希望增加固定标头的z-index。详细了解z-index herehere

答案 1 :(得分:0)

我认为那里的图像让你的内容隐藏在标题后面你可以清楚地看到像字母图像,它的位置是绝对找到它并检查它的z-index并给你的内容z-index少于它以便它仍然落后于