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/