javascript - CSS 和 JavaScript 菜单问题

标签 javascript html css

所以我正在为学校编写一个网站。我编写了一个侧面菜单,其中包含您可以单击的选项。我还对您点击的一些内容进行了编码。我的问题是,即使它们存在,它也会说“filler.html 不存在”。当我点击时。尽管它们存在。所以,这是我的代码。如果您有任何其他问题,请提出。

function openNav() {
  document.getElementById("mySidenav").style.width = "250px";
}

function closeNav() {
  document.getElementById("mySidenav").style.width = "0";
}
body {
  font-family: "Lato", sans-serif;
}

.ABox {
  background-color: black;
  color: lightgrey;
  width: auto;
  padding: 1%;
}

.sidenav {
  height: 100%;
  width: 0;
  position: fixed;
  z-index: 1;
  top: 0;
  left: 0;
  background-color: #111;
  overflow-x: hidden;
  transition: 0.5s;
  padding-top: 60px;
}

.sidenav a {
  padding: 8px 8px 8px 32px;
  text-decoration: none;
  font-size: 25px;
  color: #818181;
  display: block;
  transition: 0.3s
}

.sidenav a:hover,
.offcanvas a:focus {
  color: #f1f1f1;
}

.closebtn {
  position: absolute;
  top: 0;
  right: 25px;
  font-size: 36px !important;
  margin-left: 50px;
}

@media screen and (max-height: 450px) {
  .sidenav {
    padding-top: 15px;
  }
  .sidenav a {
    font-size: 18px;
  }
}
<div id="mySidenav" class="sidenav">
  <a href="javascript:void(0)" class="closebtn" onclick="closeNav()">×</a>
  <br>
  <a href="/StoryTime.html">The beginning of logic and rhetoric</a>
  <a href="/rhetoric.html">What is rhetoric?</a>
  <a href="/classics.html">What is classics?</a>
  <a href="/timeline.html" Timeline</a>
</div>

<div class="ABox">
  <h2>Classics and Rhetoric</h2>
</div>
<p style="background-color:black;color:lightgrey;width:200px;padding:1%;"></p>
<span style="font-size:30px;cursor:pointer" onclick="openNav()">☰</span>

最佳答案

尝试删除前导“/”。当您需要相对目录时,这意味着绝对目录。

<a href="StoryTime.html">The beginning of logic and rhetoric</a>
<a href="rhetoric.html">What is rhetoric?</a>
<a href="classics.html">What is classics?</a>
<a href="timeline.html">Timeline</a>

关于javascript - CSS 和 JavaScript 菜单问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43764763/

相关文章:

javascript - webGL 在事件处理程序中绘制似乎清除了 Canvas

javascript - HighChart 标记突出显示/工具提示问题,突出显示标记不移动

html - 我有 3 列,滚动时需要让中间列保持不变

css - z-index和css Position :?有什么关系

html - 如何在CSS中没有固定高度的情况下将文本定位在图像上

css - 使用 CSS 使按钮出现在 Chrome/Webkit 浏览器中的“选择下拉”菜单上

javascript - 如何通过匹配包含的文本来填充下拉选择框?

javascript - 获取特定数据属性的所有值

html - 停止 jupyter notebook 在 pandas html 表输出中包装单元格内容

javascript - jquery移动设备旋转缩小屏幕