CSS-HTML样式元素无法使用样式

奥利弗·丹尼(Oliver Denny)

我目前正在尝试为滑动式侧面菜单编写CSS,作为个人项目的一部分。现在,我的问题是侧边栏中的文本菜单项的样式(请参阅下面的aside元素,类为“ nav-sidebar”)不是从CSS表单中获得的。以下是HTML ...

和CSS(底部没有出现的样式):

* {
  margin: 0px;
  padding: 0px;
}

header {
  position: sticky;
  background: #404040;
  height: 85px;
  margin: 0px;
  padding: 0px;
  width: 100%;
}

header::before {
  content: '';
  display: block;
  margin: 0px;
  height: 5px;
  background-color: #8EFA00;
}

.nav-main {
  position: fixed;
  top: 0;
  width: 100%;
  height: 60px;
  display: flex;
  flex-wrap: wrap;
}

.btn-toggle-nav {
  width: 60px;
  height: 100%;
  margin-top: 10px;
  margin-left: 10px;
  background-color: #8EFA00;
  border-radius: 50%;
  background-image: url(imgs/menu.png);
  background-repeat: no-repeat;
  background-size: 60%;
  background-position: center;
  cursor: pointer;
}

.btn-toggle-nav:hover {
  opacity: 0.5;
}

.nav-main ul {
  text-align: center;
  padding-top: 0px;
  padding-left: 500px;
  display: flex;
  flex-wrap: wrap;
}

.nav-main ul li {
  list-style: none;
  line-height: 60px;
}

.nav-main ul li a {
  display: block;
  height: 100%;
  padding: 0 10px;
  text-transform: uppercase;
  text-decoration: none;
  color: white;
  font-family: arial;
  font-size: 16px;
}

.nav-sidebar {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 50px;
  padding: 0 5px;
  height: calc(100vh - 60px);
  background-color: #1b1b1b;
  z-index: 1000;
}

.nav-sidebar aside ul {
  padding-top: 15px;
  text-decoration: none;
}

.nav-sidebar aside ul li {
  line-height: 60px;
  list-style: none;
  text-decoration: none;
}

.nav-sidebar aside ul li span .nav-sidebar aside ul li a {
  display: block;
  height: 60px;
  padding: 0 10px;
  text-decoration: none;
  text-transform: uppercase;
  color: white;
  font-family: arial;
  font-size: 16px;
}
<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8">
  <title>Posidiff</title>
  <link rel="shortcut icon" type="image/png" href="imgs/favicon.png">
  <link rel="stylesheet" href="style.css">
</head>
<header>
  <nav class="nav-main">
    <div class="btn-toggle-nav"></div>
    <ul>
      <li><a href="index.html">Home</a></li>
      <li><a href="about.html">About</a></li>
      <li><a href="features.html">Features</a></li>
      <li><a href="contactus.html">Contact us</a></li>
    </ul>

  </nav>

  <aside class="nav-sidebar">
    <ul>
      <li><span>Home</span></li>
      <li><a href=#>About</a></li>
      <li><a href=#>Features</a></li>
      <li><a href=#>Contact us</a></li>
    </ul>
  </aside>
</header>

<body>
</body>

</html>

为了提供一些上下文,我同时包含了HTML和CSS文档的全部内容,但是现在我只对ul / li中“ nav-sidebar”类中项目的样式感兴趣。

我尝试在其他浏览器中进行检查(野生动物园-尽管我在chrome中使用它),并在css doc中进行了一两个调整,但无济于事。

我还想提到我对HTML和CSS还是相当陌生,所以在这里也很可能还有其他错误!

所以-最终我的问题是,为什么“ .nav-sidebar除了ul li span”无法通过此处的样式

提前谢谢了!

里昂

您缺少“ span”和“ aside”之间的逗号。应该

aside.nav-sidebar ul li span,aside.nav-sidebar ul li a

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章