html - CSS 水平菜单栏在 Internet Explorer 中显示正确,在 Google Chrome 中显示无样式

标签 html css web menubar

CSS 水平菜单栏在 Internet Explorer 中显示正确,在 Google Chrome 中显示无样式..

ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: #333;
  position: relative;
  top: 0;
  width: 100%;
}

li {
  float: left;
}

li a {
  display: inline-block;
  color: white;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
}

li a:hover:not(.active) {
  background-color: #111;
}

.active {
  background-color: #4CAF50;
}
<ul>
  <li><a class="active" href="#home">Home</a></li>
  <li><a href="#news">News</a></li>
  <li><a href="#contact">Contact</a></li>
  <li><a href="#about">About</a></li>
</ul>

Chrome 只是显示一个带有

  • 标签作为链接的元素符号列表。未应用任何样式。

  • 最佳答案

    它会工作,你可能在正确包含 css 文件时犯了一些错误,或者你必须清除缓存..使用 Ctrl+Shift+R 或从谷歌浏览器的设置中清除浏览器缓存(或执行硬 Reload+ emptycache )

    我在这里添加工作代码。试试吧

    ul {
    list-style-type: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: #333;
    position: relative;
    top: 0;
    width: 100%;
    }
    
    li {
    float: left;
    }
    
    li a {
    display: inline-block;
    color: white;
    text-align: center;
    padding: 14px 16px;
    text-decoration: none;
    }
    
    li a:hover:not(.active) {
    background-color: #111;
    }
    
    .active {
    background-color: #4CAF50;
    }
    <!DOCTYPE html>
    <html>
    <head>
    	<title></title>
    	<link rel="stylesheet" type="text/css" href="style.css">
    </head>
    <body>
    <ul>
    <li><a class="active" href="#home">Home</a></li>
    <li><a href="#news">News</a></li>
    <li><a href="#contact">Contact</a></li>
    <li><a href="#about">About</a></li>
    </ul>
    
    </body>
    </html>

    关于html - CSS 水平菜单栏在 Internet Explorer 中显示正确,在 Google Chrome 中显示无样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44582719/

    相关文章:

    html - 带砌体的全宽画廊

    javascript - 动态改变href

    jquery - 切换菜单时背景变灰

    html - 水平图像滚动,里面的文字太过分了

    perl - 如何使用 Perl Dancer 服务 robots.txt

    javascript - 如何对齐正文中的 div 以保持特定的高度和宽度

    javascript - 我想将选定的元素从一个列表移动到另一个列表

    html - 从 html 中的 <a> 标签中删除标签大纲

    javascript - 我的 api 调用在 javascript 中不起作用,但在 postman 和浏览器中工作正常

    asp.net - 由于以下错误 : 80040154,检索具有 CLSID {88D969C1-F192-11D4-A65F-0040963251E5} 的组件的 COM 类工厂失败