HTML 相对路径会导致导航菜单中出现 404 错误



我的导航菜单中有 6 个文件连接到服务器上public_html主文件夹内的文件夹。我使用<nav>作为我的标签之一,因为我正在连接到包含菜单布局的外部 css 样式表。

这是我的HTML菜单:

<center>
<nav>
<ul id="mainMenu">
<li><a href="public_html/Dome1/art.html">Art Dome</a></li>
<li><a href="public_html/Dome2/music.html">Music Dome</a></li>
<li><a href="public_html/Dome3/code.html">Dome Unknown</a></li>
<li><a href="https://www.google.com/maps/search/scrap+metal+near+me/@41.4745193,-81.7553814,14z/data=!3m1!4b1">Hunger Dome</a></li>
<li><a href="https://www.wikipedia.org/wiki/special:Random">Education Dome</a></li>
<li><a href="public_html/Dome6/yesno.html">Yes or No Dome</a></li>
<!--yesno dome has green circle with yellow text saying "yes"-->
<li><a href="public_html/Dome7/dontgo.html">Do Not Go Into This Dome!</a></li>
<!--do not dome: red circle with text saying: you have entered into the wrong dome. Go back.-->
<li><a href="public_html/Contact Dome/contact.html">Contact</a></li>
</ul>
</nav>
</center>

如您所见,它有点断断续续,但我想添加相对路径,例如:Dome1/art.html等。有什么提示吗?

首先,<center></center>不再是有效的HTML。改为构建一个 CSS 类。它与HTML5不兼容。也就是说,您的路径不应包含public_html文件夹。我重写了你的导航。

.text-center {
text-align: center;
}
<nav class="text-center">
<ul id="mainMenu">
<li><a href="dome1/art.html">Art Dome</a></li>
<li><a href="dome2/music.html">Music Dome</a></li>
<li><a href="dome3/code.html">Dome Unknown</a></li>
<li><a href="https://www.google.com/maps/search/scrap+metal+near+me/@41.4745193,-81.7553814,14z/data=!3m1!4b1">Hunger Dome</a></li>
<li><a href="https://www.wikipedia.org/wiki/special:Random">Education Dome</a></li>
<li><a href="dome6/yesno.html">Yes or No Dome</a></li>
<!--yesno dome has green circle with yellow text saying "yes"-->
<li><a href="dome7/dontgo.html">Do Not Go Into This Dome!</a></li>
<!--do not dome: red circle with text saying: you have entered into the wrong dome. Go back.-->
<li><a href="contact-dome/contact.html">Contact</a></li>
</ul>
</nav>

相关内容

  • 没有找到相关文章

最新更新