scaldings
scaldings

Reputation: 33

HTML, CSS: Responsive navigation bar drawing under text

I have been working on a new site and when I was trying to use the navigation bar (while in mobile device mode) the navigation bar started drawing under the text. I have checked the code from my previous website and I just do not understand why it does not work. I can't even interact with the navigation bar.

Here is what happens: https://gyazo.com/91ca07c2fafd81355152f5c2379fd89d

Here is the code: HTML:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" href="./css/style.css" />
    <link
      rel="stylesheet"
      href="https://use.fontawesome.com/releases/v5.14.0/css/all.css"
      integrity="sha384-HzLeBuhoNPvSl5KYnjx0BT+WB0QEEqLprO+NBkkk5gbc67FTaL7XIGa2w1L0Xbgc"
      crossorigin="anonymous"
    />
    <script src="https://kit.fontawesome.com/a076d05399.js"></script>
    <title>Landing Page</title>
  </head>
  <body>
    <div class="main">
      <nav>
        <input type="checkbox" id="check" />
        <label for="check" class="checkbutton">
          <i class="fas fa-bars"></i>
        </label>
        <img src="./img/logo.png" alt="Logo" />
        <ul>
          <li><a class="active" href="./">Home</a></li>
          <li><a href="#">Store</a></li>
          <li><a href="#">Download</a></li>
        </ul>
      </nav>
      <main>
        <div class="header"><p>Example Client</p></div>
        <div class="description">
          <p>
            Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi id
            pharetra metus. Nullam sit amet lorem sapien. Aliquam commodo
            pretium.
          </p>
        </div>
        <div class="footer">
          <a href="https://t.me/scaldings">
            <i class="d-block fab fa-telegram text-muted fa-lg mx-2"></i>
          </a>
          <a href="https://discord.com/channels/@me/394894093437763594">
            <i class="d-block fab fa-discord text-muted fa-lg mx-2"></i>
          </a>
          <p>© Example Client</p>
        </div>
      </main>
    </div>
  </body>
</html>

CSS:

@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@500&display=swap");
::-webkit-scrollbar {
  display: none;
}
* {
  margin: 0;
  padding: 0;
  text-decoration: none;
  list-style: none;
  box-sizing: border-box;
}
body {
  font-family: "Poppins", sans-serif;
}
.main {
  width: 100vw;
  height: 100vh;
  background: url("/img/bg.jpg") no-repeat;
  background-size: cover;
}
nav {
  height: 100px;
  width: 100%;
  background: rgba(97, 97, 97, 0.4);
}
/*Logo*/
nav img {
  width: 80px;
  float: left;
  margin-top: 10px;
  margin-left: 80px;
  transition: 0.3s;
}
nav img:hover {
  filter: brightness(80%);
}
/*Logo*/

/*Navigation links*/
nav ul {
  float: right;
  margin-right: 80px;
}
nav ul li {
  display: inline-block;
  line-height: 100px;
  margin: 0 10px;
  font-size: 20px;
}
nav ul li a {
  padding: 0 10px;
  color: #ffffff;
  transition: 0.3s;
}
nav ul li a:hover {
  color: #bdbdbd;
}
a.active {
  border: 1.9px solid #ffffff;
  border-radius: 1px;
}
a.active:hover {
  border: 1.9px solid #bdbdbd;
}
.checkbutton {
  float: right;
  line-height: 100px;
  margin-right: 80px;
  color: #ffffff;
  font-size: 30px;
  transition: 0.3s;
  cursor: pointer;
  display: none;
}
.checkbutton:hover {
  color: #bdbdbd;
}
#check {
  display: none;
}
/*Navigation links*/

/*Main wrapper*/
main {
  height: calc(100vh - 100px);
  position: relative;
}
.header {
  position: absolute;
  top: 30%;
  left: 50%;
  margin-right: -50%;
  transform: translate(-50%, -50%);
  font-size: 72px;
  color: #ffffff;
  transition: 0.3s;
}
.description {
  text-align: center;
  position: absolute;
  top: 40%;
  left: 50%;
  margin-right: -50%;
  transform: translate(-50%, -50%);
  width: 600px;
  font-size: 18px;
  color: #d8d8d8;
  word-wrap: normal;
  transition: 0.3s;
}
.footer {
  position: absolute;
  float: left;
  bottom: 0;
  margin-left: 10px;
  color: #ffffff;
}
.footer a {
  color: #ffffff;
}
.footer a:hover {
  color: #bdbdbd;
}
/*Main wrapper*/

/*Responsive part*/
@media (max-width: 952px) {
  nav ul li a {
    font-size: 20px;
  }
  main h1 {
    font-size: 64px;
  }
}
@media (max-width: 858px) {
  .checkbutton {
    display: block;
  }
  ul {
    position: fixed;
    width: 100%;
    height: 100vh;
    background-color: rgba(97, 97, 97, 0.4);
    top: 100px;
    left: -100%;
    text-align: center;
    transition: all 0.8s;
  }
  nav ul li {
    display: block;
    margin: 60px 0;
  }
  nav ul li a {
    font-size: 20px;
  }
  main h1 {
    font-size: 60px;
  }
  #check:checked ~ ul {
    left: 0;
  }
}
/*Responsive part*/

Thank you in advance!

Upvotes: 0

Views: 112

Answers (1)

Besufkad Menji
Besufkad Menji

Reputation: 1588

Increase z-index of the if the element you want to be on top. simple example:

.below-item{
      z-index:1;
}
.top-item{
      z-index:2;
}

Upvotes: 1

Related Questions