我正在尝试制作横向菜单
但这些空块位于我的菜单项(aprox 50px x 50px)
之间我使用了chrome检查工具,这些随机的空白锚点里面没有任何内容,最后是== $ 0
.navbar{
overflow: hidden;
position: fixed;
top: 0;
left: 0;
width: 100%;
background-color: red;
}
.navbar a{
float: left;
display: block;
text-align: center;
padding: 30px 25px;
border: none;
margin: none;
text-decoration: none;
font-size: 20px;
}
.navbar a:hover {
background: #54d5f2;
color: black;
}

<html>
<head>
<title>I Want Flowers</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="navbar">
<a href="./homepage.html">Home Page<a/>
<a href="./products.html">Products<a/>
<a href="./storelocations.html">Store Locations</a>
<a href="./contactus.html">Contact Us</a>
</div>
</body>
</html>
&#13;
答案 0 :(得分:1)
这是因为您关闭<a>
这样的结果:<a/>
而不是</a>
:
<a href="./homepage.html">Home Page<a/>
<a href="./products.html">Products<a/>
答案 1 :(得分:0)
我认为你在关闭锚标签时犯了错误
<a href="./homepage.html">Home Page<a/>
到
<a href="./homepage.html">Home Page</a>
答案 2 :(得分:0)
用这个HTML替换HTML
<div class="navbar">
<a href="./homepage.html">Home Page</a>
<a href="./products.html">Products</a>
<a href="./storelocations.html">Store Locations</a>
<a href="./contactus.html">Contact Us</a>
</div>
答案 3 :(得分:0)
这是不应该关闭锚标签的后续效果。
只需将<a/>
更改为</a>
,您就可以了......:)
.navbar{
overflow: hidden;
position: fixed;
top: 0;
left: 0;
width: 100%;
background-color: red;
}
.navbar a{
float: left;
display: block;
text-align: center;
padding: 30px 25px;
border: none;
margin: none;
text-decoration: none;
font-size: 20px;
}
.navbar a:hover {
background: #54d5f2;
color: black;
}
<html>
<head>
<title>I Want Flowers</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="navbar">
<a href="./homepage.html">Home Page</a>
<a href="./products.html">Products</a>
<a href="./storelocations.html">Store Locations</a>
<a href="./contactus.html">Contact Us</a>
</div>
</body>
</html>