2013-04-25 48 views
3

我使用position的值fixed,以便在用户向下滚动时标头保持原位。CSS固定标头 - 放大时无法访问标签

enter image description here

的问题是,如果我在我变焦无法查看或访问我的一些标签,例如:

enter image description here

有没有办法放大,仍然是能够看到和访问我的标签?

我的代码:

JSFIDDLE CODE

HTML:

<div id="top"> 
    <header> 
     <hgroup> 
      <h1>LOGO</h1> 
     </hgroup> 
     <nav> 
      <ul> 
       <li class="tabs"><a href="#">First</a></li> 
       <li class="tabs"><a href="#">Second</a></li> 
       <li class="tabs"><a href="#">Third</a></li> 
       <li class="tabs"><a href="#">Fourth</a></li> 
      </ul> 
     </nav> 
    </header> 

CSS:

#top { 
    background-color: #1b1b1b; 
    box-shadow: 0px 0px 9px rgba(0,0,0,0.15); 
    padding: 20px 100px; 
    width: 100%; 
    height: 70px; 
    z-index: 99999; 
    position: fixed; 
    top: 0; 
    left: 0; 
} 
header { 
    position: relative; 
    width: 440px; 
    height: 70px; 
    margin: 0 auto; 
} 
header hgroup { 
    position: absolute; 
    display: block; 
    top: 5px; 
    left: -50px; 
} 
header hgroup h1 { 
    font-size: 50px; 
    color: #fff; 
    display: block; 
    height: 100px; 
    width: 610px; 
} 
nav { 
    float: right; 
} 
nav ul li:hover > ul { 
    display: block; 
} 
nav ul { 
    margin-top: 10px; 
    padding: 0 20px; 
    list-style: none; 
    position: relative; 
    display: inline-table; 
    margin-right: -80px; 
} 
nav ul:after { 
    content: ""; 
    clear: both; 
    display: block; 
} 
nav ul li { 
    float: left; 
} 
nav ul li:hover { 
    color: #fff; 
} 
.tabs:hover { 
    border-bottom: 5px solid #fff; 
} 
nav ul li a:hover { 
    color: #fff; 
} 
nav ul li a { 
    display: block; 
    padding: 15px 15px;  
    font-family: 'PT Sans', sans-serif; 
    color: #fff; 
    text-decoration: none; 
} 
+0

你应该瞄准一个液态布局...现在每次测量是固定的,而只有位置你的禁止应该是固定的,并在其中的元素相对于它们各自的位置... – sg3s 2013-04-25 16:18:16

+0

是[this](http://stackoverflow.com/questions/8025818/unable-to-get-the-scroll-when-positionfixed-元素 - 消失 - 形式 - scr/8026202#8026202)任何帮助? – 2013-04-25 16:23:01

+0

它似乎没有工作。 – kalpetros 2013-04-25 16:31:00

回答

3

不要使用固定宽度为您header,使用100%代替:

#top { 
    background-color: #1b1b1b; 
    box-shadow: 0px 0px 9px rgba(0,0,0,0.15); 

    width: 100%; 
    height: 70px; 
    z-index: 99999; 
    position: fixed; 
    top: 0; 
    left: 0; 
} 
header { 
    position: relative; 
    width: 100%; 
    height: 70px; 
    margin: 0 auto; 
} 

Updated Fiddle