1

不知何故,我的导航标题元素不会浮动到右上角的位置:固定。

有人有想法吗?

我真的很期待回答这个小谜团。

这是代码:

<header class="hidden" style="z-index:40000; float:right;"> 
  <div class="wrapper hidden" id="test"> 
    <nav class="work-nav menu">
      <ul class="navscroll">
        <a href="#headerwrap" rel="tooltip" data-placement="left" title="Home">
          <li><img src="img/nav_bar_home_02.png"></li>
        </a>
        <a href="http://www.designlike.de/g_website_test/work-overview.htm" rel="tooltip" data-placement="left" class="transition" title="Work">
          <li><img src="img/nav_bar_work_02.png"></li>
        </a>
        <a href="#footerscroll" rel="tooltip" data-placement="left" title="Contact">
          <li><img src="img/nav_bar_contact_02.png"></li>
        </a>
      </ul>
    </nav>
  </div> 
</header> 

和CSS:

/* ------ */
/* HEADER */
/* ------ */
header {
    display:block;
    position:fixed;
    top: 0;
    left: 0;
    width: 40px;
    overflow:visible;
    z-index:20000;
    float:right; !important
}
header .wrapper {
    position: fixed;
    padding-top: 0px;
    padding-bottom: 20px;
    height: 60px;
    float:right;
}
nav {  
    float:right;
    width:40px;
    margin-top:-1px; 
}
nav ul { margin:0px; padding:0px; position:fixed;}
nav ul li {
    width:40px;
    min-height: 40px;
    background-color:#ffd200;
    margin-top:1px;
    padding:0;
    list-style:none;
    -webkit-transition: all 0.15s ease-in-out;
    -moz-transition: all 0.15s ease-in-out;
    -ms-transition: all 0.15s ease-in-out;
    -o-transition: all 0.15s ease-in-out;
    transition: all 0.15s ease-in-out;
}

nav ul li:hover {
    width:40px;
    min-height: 40px;
    background-color:#2a2a2a;
} 

nav a {
    color: #fff;
    cursor: pointer;
    display:block;
    text-decoration:none;
    width:100%;
}

nav a:hover{
    text-decoration:none;
}

nav li:hover {
    position: relative;
}
4

1 回答 1

3

你不能使用position: fixed;with float: right;。其中一个是告诉它存在于特定的像素位置,而另一个是告诉它在其容器中浮动。他们是相互矛盾的指令,并且position会获胜。

left: 0也就是说,我相信您可以通过简单地更改right: 0和完全删除来实现您正在尝试的目标float

于 2013-03-29T12:16:52.000 回答