2013-08-07 119 views
0

我试图用CSS创建一个浮动菜单。当我向下滚动标题图像时,我想让div粘贴到顶部。我尝试使用“位置:固定”,但这留下了一个空白。无论如何将菜单包装div从相对转换为固定的? enter image description hereDiv相对于固定

CSS

/*** Header ***/ 
#header   { width: 100%; background-color: #000; z-index: 2000; height: 50px; margin: 0 0; border-top: 1px solid #464646; border-bottom: 1px solid #464646; position: fixed} 
#topheader  {height: 110px; background: #333; width:970px; margin: 0 auto; position: relative;} 
#topheadleft {float: left; width: 50%; font-family: font1; font-size: 46px; margin-top: 15px; } 
#topheadright {float: left; width: 50%} 
.callus { color: #fff; font-size: 20px; font-family: font4; text-shadow: 2px 2px #000} 
.hardwork {color: #fff; font-family: font3; font-size: 12px; text-transform:capitalize; } 
#topheadwrap { background: #333; padding: 0 0; margin: 0 auto; } 
.fixed { position:fixed; top:0; } 

HTML

<div id="topheadwrap"> 
     <div id="topheader"> 
       <div id="topheadleft"> 
         <span style="color:#FF4B45; text-shadow: 2px 2px #000;">East Coast</span><span style="color: #3A8CFF; text-shadow: 2px 2px #000;"> Martial Arts</span><br /> 
         <div style="margin-top:-30px; clear: both"><span class="callus">Call Us Now: 845-440-7715</span></div> 
         <div style="margin-top:-35px; clear: both"><span class="hardwork">Hard work, dedication, challenging, authentic</span></div> 
       </div> 
      <div id="topheadright"></div> 
     </div> 
    </div> 


    <div id="header"> 

     <div id='cssmenu'> 
<ul> 
    <li><a href='#'><span>Home</span></a></li> 
    <li class='has-sub'><a href='?page_id=39#box3'><span>About Us</span></a> 
     <ul> 
     <li class='has-sub'><a href='#'><span>The School</span></a> 
     </li> 
     <li class='has-sub'><a href='http://www.eastcoastma.com/?page_id=158'><span>Instructors</span></a> 
     </li> 

     </ul> 
    </li> 
    <li><a href='?page_id=56'><span>Classes</span></a></li> 
    <li><a href='?page_id=15'><span>Schedule</span></a></li> 
    <li><a href='#'><span>News</span></a></li> 
    <li><a href='?page_id=69'><span>Programs</span></a></li> 
    <li class='last'><a href='page_id=29 '><span>Contact</span></a></li> 
</ul> 
</div> 
+0

当然有。我们可以看到你试图做到这一点吗? – Ohgodwhy

+0

向我们显示您的标记? –

+0

附加标记,很抱歉 – RomeNYRR

回答