我的标题图片跟随向下滚动

时间:2014-05-18 17:43:22

标签: html css html5 css3

我试图为手机创建一个左侧菜单,但我有一个问题:
当我滚动我的内容时,我的标题图像跟随滚动并隐藏了一些内容。我需要将标题修复到它的位置......

以下是我的问题的演示:http://jsfiddle.net/th46k/7/

我的 Html

<header id="top">   
    <span id="logo"><a href="index.php"><img  src="http://placehold.it/350x150" /></a></span>
</header>
<div id="menu">
    <ul>
        <li><a href="#">Menu Item 1</a>
        </li>
        <li><a href="#">Menu Item 2</a>
        </li>
        <li><a href="#">Menu Item 3</a>
        </li>
    </ul>
</div>
<div id="right">
    <div id="menubar">
        <div id="button">Menu</div>
    </div>
    <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
    <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
    <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
</div>

这是我的 CSS

 * {
     padding: 0px;
     margin: 0px;
 }
 #top {
     width:226px;
     margin:10px auto 10px auto;
 }
 #logo {
     float:left;
 }
 #menubar {
     width:100%;
     background-color:#444;
     color: #fff;
     padding: 10px;
 }
 #button {
     cursor:pointer;
 }
 #menu, #right {
 }
 #menu li a {
     padding: 10px;
     display: block;
     color: white;
     text-decoration: none;
 }
 #right {
     width:100%;
     background-color: #fff;
     z-index: 5;
     position: fixed;
     overflow: scroll;
     left: 0px;
     height: 100%;
     -webkit-box-shadow: -5px 0px 4px 0px rgba(0, 0, 0, 0.2);
     moz-box-shadow: -5px 0px 4px 0px rgba(0, 0, 0, 0.2);
     o-box-shadow: -5px 0px 4px 0px rgba(0, 0, 0, 0.2);
     box-shadow: -5px 0px 4px 0px rgba(0, 0, 0, 0.2);
 }
 #right p {
     padding: 10px;
 }
 #menu {
     float:left;
     width: 350px;
     height: 100%;
 }
 #menu li {
     background-color:#444;
     border-bottom: 1px solid #888;
 }

1 个答案:

答案 0 :(得分:0)

以下是与您的要求相关的示例。滚动页面时,标题区域将粘在顶部。根据您的要求做一些更改。希望它会对你有所帮助。

Demo