html - Chrome 中的导航栏定位错误

标签 html css google-chrome html-lists css-position

我在 chrome 中遇到了一个奇怪的 css 定位问题。我有一个菜单 <ul>用于有时被随机下推的导航。刷新页面总能解决问题。奇怪的是,有时如果我在页面正确显示时刷新页面,它会被下推。

这是它应该看起来的样子,而且它在大约一半的时间里是这样的:

enter image description here

这就是它由于某种原因被推下时会发生的情况。

enter image description here

本站已上线,问题可自行体验here .可能需要在网站周围点击一下才能获得 <ul>下降。

这是 html/php我正在使用:

<div class="header">
<nav class="navbar">
  <a href="<?php echo url("home") ?>" class="title"><?php echo strtoupper($site->title())?></a>
  <ul>
    <?php foreach($pages->visible() AS $p): ?>
    <li><a<?php echo ($p->isOpen()) ? ' class="active"' : '' ?> href="<?php echo (strtolower(($p->title)) == "work") ? url("home") : $p->url(); ?>"><?php echo html($p->title()) ?></a></li>
    <?php endforeach ?>
  </ul>
</nav>
</div>

与相关css :

 div.header{
   height: 80px;
   background-color: #000000;
   margin-bottom: 20px;
 }
 div.header nav.navbar{
   width: 960px;
   margin: auto;
   padding-top: 20px;
 }

 .navbar ul{
   float: right;
   padding-top: 10px;
   display: inline;
   list-style-type: none;
 }

.navbar ul li{
  margin-left: 20px;
  display: inline;
 }

.navbar a.title{
  width: 500px;
  color: #fff;
  font-size: 26pt;
  display: inline-block;
  padding-top: 8px;
}

同样,我只在谷歌浏览器中遇到过这个问题。 感谢您的帮助!

最佳答案

从来没有想出问题,但我使用绝对定位作为解决方法。

关于html - Chrome 中的导航栏定位错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17822050/

相关文章:

jquery - 如何删除悬停音频播放和标题

javascript - 如何在 jquery (coffeescript) 中有条件地添加 css 属性

javascript - 在 Javascript 中添加注释/注释的示例代码

html - 如何让我的应用程序在移动设备上填满整个高度?

css - FF4 中的填充错误

php - Wordpress:is_page() if 语句未显示内容

javascript - 使用 Javascript 在 div 中画线

javascript - Fetch Promise 被 Chrome 的缓存阻止

css - 如何在 Google Chrome 浏览器中使用断字?

html - 我的下拉导航菜单有什么问题? [可能的问题]