All body content moves up and below the navigation (HTML & CSS)

I've tried a few suggestions like removing overflow from the body, adding a z-index to header and padding-top but nothing seems to work.

It worked fine at first but then I implemented a lot of Lorem Ipsum text. All the content just slides up and below the navbar. I've attached a JS fiddle to explain.

I tried the whole body overflow and tried the fixed/relative header positions. Nothing works.

Any input would seriously be appreciated A LOT.

I would love some help in how can I make the nav stick but not really stay fixed when I scroll down.

And of course, how to make the contents not overflow horizontally.

Please help!

CSS

html,
body {
  position: absolute;
  width: 100%;
  top: 0;
  min-height: 100vh;
  font-family: sans-serif;
  margin: 0 !important;
  padding: 0 !important;
}



ul {
  box-sizing: border-box;


}

#logo {
  max-width: 15%;
}




.menu-wrapper {
  background-color: white;
}

.header {
  z-index: 1000;
  width: 100%;
  margin: 1.2em;
  position: fixed;
  background-color: black;


}






#about {
  position: absolute;
  max-width: 100%;
  top: 49%;
  left: 50%;
  transform: translate(-50%, -50%);
  border: 5px solid purple;
  padding: 20px;
  text-align: center;
  justify-content: center;
}

.about-par {
  font-size: 1em;
}



.header ul {
  padding: 0;
  list-style: none;
  overflow: hidden;
  margin-right: 2em;

}

.header li a {
  display: block;
  color: blue;
  text-decoration: none;
  font-size: 1em;
}

.header li a:hover,
.header .menu-btn:hover {
  color: black;
}

.header li a:active,
.header .menu-btn: active,
  {
  color: blue;
}

.header li a:active {
  color: blue;
}

.header .logo {
  color: black;
  display: block;
  float: left;
  font-size: 1.1em;
  padding: 12px;
  margin-left: 1em;
  text-decoration: none;
}

.header .menu {
  clear: both;
  max-height: 0;
  transition: max-height 0.2s ease-out;
}

/* menu icon */
.header .menu-icon {
  cursor: pointer;
  display: inline-block;
  float: right;
  padding: 28px 40px;
  position: relative;
  user-select: none;
}

.header .menu-icon .navicon {
  display: block;
  height: 2px;
  position: relative;
  transition: background 0.2s ease-out;
  width: 18px;
}

.header .menu-icon .navicon:before,
.header .menu-icon .navicon:after {
  background: black;
  content: "";
  display: block;
  height: 100%;
  position: absolute;
  transition: all 0.2s ease-out;
  width: 100%;
}

.header .menu-icon .navicon:before {
  top: 5px;

}

.header .menu-icon: before {
  background: transparent;
}

.header .menu-icon .navicon:after {
  top: -5px;

}

/* menu btn */
.header .menu-btn {
  display: none;
}

.header .menu-btn:checked~.menu {
  max-height: 340px;
  background-color: black;
}

.header .menu-btn:checked~.menu-icon .navicon {
  background: transparent;
}

.header .menu-btn:checked~.menu-icon .navicon:before {
  transform: rotate(-45deg);
}

.header .menu-btn:checked~.menu-icon .navicon:after {
  transform: rotate(45deg);

}

.header .menu-btn:checked~.menu-icon:not(.steps) .navicon:before,
.header .menu-btn:checked~.menu-icon:not(.steps) .navicon:after {
  top: 0;
}

/* Responsive */
@media only screen and (max-width: 768px) {
  .header li a {
    padding: 15px;
    border-bottom: 1px dotted #ddd;
    color: white;
  }

  .header li a:hover {
    padding: 15px;
    border-bottom: 1px dotted #ddd;
    color: blue;




  }


}

@media only screen and (min-width: 768px) {
  .menu-wrapper {
    width: 100%;
  }


  .header li {
    float: left;
  }

  .header .logo {
    line-height: 1;
  }

  .header li a {
    color: blue;
    padding: 0px 30px;
    border-right: 1px solid rgba(255, 255, 255, 0.2);

  }

  .header .menu {
    clear: none;
    float: right;
    max-height: none;

  }

  .header .menu-icon {
    display: none;

  }
}

HTML

<!DOCTYPE html>

<html lang="en">

  <head>


    <script src="script.js"></script>

    <link href="style.css" rel="stylesheet">
    <meta charset="utf-8">

    <link href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css" rel="stylesheet">


    <meta name="viewport" content="initial-scale=1, width=device-width shrink-to-fit=no">



    <title>Hello! </title>

  </head>

  <body>

    <div class="empty"></div>
    <div class="all">
      <div class="menu-wrapper">
        <header class="header">
          <a href="#home">Logo</a>
          <input class="menu-btn" type="checkbox" id="menu-btn" />
          <label class="menu-icon" for="menu-btn"><span class="navicon"></span></label>
          <ul class="menu">
            <li><a href="#">Home</a></li>
            <li><a href="about.html">About Us</a></li>
            <li><a href="#">More</a></li>
            <li><a href="#">More2</a></li>
          </ul>
        </header>
      </div>
    </div>

    <div class="row">
      <div class="container-fluid" id="about">
        <h5>Text</h5>
        <div class="col-lg-12">
          <article>
            <p class="about-par">
              Pellentesque in ipsum id orci porta dapibus. Cras ultricies ligula sed magna dictum porta. Curabitur arcu erat, accumsan id imperdiet et, porttitor at sem. Vivamus magna justo, lacinia eget consectetur sed, convallis at tellus. Praesent sapien massa, convallis a pellentesque nec, egestas non nisi. Quisque velit nisi, pretium ut lacinia in, elementum id enim. Proin eget tortor risus. Quisque velit nisi, pretium ut lacinia in, elementum id enim. Vivamus suscipit tortor eget felis porttitor volutpat. Proin eget tortor risus. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
              <br>Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec velit neque, auctor sit amet aliquam vel, ullamcorper sit amet ligula. Pellentesque in ipsum id orci porta dapibus. Vivamus suscipit tortor eget felis porttitor volutpat. Proin eget tortor risus. Vivamus suscipit tortor eget felis porttitor volutpat.
              <br>
              Donec sollicitudin molestie malesuada. Nulla quis lorem ut libero malesuada feugiat. Vivamus magna justo, lacinia eget consectetur sed, convallis at tellus. Curabitur arcu erat, accumsan id imperdiet et, porttitor at sem. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur aliquet quam id dui posuere blandit. Vivamus magna justo, lacinia eget consectetur sed, convallis at tellus.
              <br>Vestibulum ac diam sit amet quam vehicula elementum sed sit amet dui. Donec sollicitudin molestie malesuada. Vivamus suscipit tortor eget felis porttitor volutpat. Vivamus suscipit tortor eget felis porttitor volutpat. Curabitur aliquet quam id dui posuere blandit. Nulla porttitor accumsan tincidunt. Nulla quis lorem ut libero malesuada feugiat. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec velit neque, auctor sit amet aliquam vel, ullamcorper sit amet ligula. Donec sollicitudin molestie malesuada.
              <br>
              Vivamus magna justo, lacinia eget consectetur sed, convallis at tellus. Cras ultricies ligula sed magna dictum porta. Proin eget tortor risus. Quisque velit nisi, pretium ut lacinia in, elementum id enim. Vestibulum ac diam sit amet quam vehicula elementum sed sit amet dui. Mauris blandit aliquet elit, eget tincidunt nibh pulvinar a. Donec sollicitudin molestie malesuada. Curabitur arcu erat, accumsan id imperdiet et, porttitor at sem. Mauris blandit aliquet elit, eget tincidunt nibh pulvinar a. Cras ultricies ligula sed magna dictum porta.
              <br>Curabitur arcu erat, accumsan id imperdiet et, porttitor at sem. Praesent sapien massa, convallis a pellentesque nec, egestas non nisi. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec velit neque, auctor sit amet aliquam vel, ullamcorper sit amet ligula. Mauris blandit aliquet elit, eget tincidunt nibh pulvinar a. Quisque velit nisi, pretium ut lacinia in, elementum id enim.
              <br>
              Praesent sapien massa, convallis a pellentesque nec, egestas non nisi. Vestibulum ac diam sit amet quam vehicula elementum sed sit amet dui. Nulla porttitor accumsan tincidunt. Curabitur aliquet quam id dui posuere blandit. Cras ultricies ligula sed magna dictum porta. Praesent sapien massa, convallis a pellentesque nec, egestas non nisi. Curabitur non nulla sit amet nisl tempus convallis quis ac lectus. Cras ultricies ligula sed magna dictum porta. Proin eget tortor risus. Praesent sapien massa, convallis a pellentesque nec, egestas non nisi. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec velit neque, auctor sit amet aliquam vel, ullamcorper sit amet ligula. Nulla porttitor accumsan tincidunt. Vivamus magna justo, lacinia eget consectetur sed, convallis at tellus. Vestibulum ac diam sit amet quam vehicula elementum sed sit amet dui. Curabitur arcu erat, accumsan id imperdiet et, porttitor at sem. Curabitur non nulla sit amet nisl tempus convallis quis ac lectus.
              <br>
              Mauris blandit aliquet elit, eget tincidunt nibh pulvinar a. Vivamus suscipit tortor eget felis porttitor volutpat. Quisque velit nisi, pretium ut lacinia in, elementum id enim. Vivamus magna justo, lacinia eget consectetur sed, convallis at tellus. Donec sollicitudin molestie malesuada. Cras ultricies ligula sed magna dictum porta. Vivamus suscipit tortor eget felis porttitor volutpat. Donec rutrum congue leo eget malesuada.
              <br>Sed porttitor lectus nibh. Curabitur aliquet quam id dui posuere blandit. Pellentesque in ipsum id orci porta dapibus. Proin eget tortor risus. Vivamus magna justo, lacinia eget consectetur sed, convallis at tellus. Mauris blandit aliquet elit, eget tincidunt nibh pulvinar a. Nulla quis lorem ut libero malesuada feugiat. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
              <br>
              Mauris blandit aliquet elit, eget tincidunt nibh pulvinar a. Vivamus suscipit tortor eget felis porttitor volutpat. Quisque velit nisi, pretium ut lacinia in, elementum id enim. Vivamus magna justo, lacinia eget consectetur sed, convallis at tellus. Donec sollicitudin molestie malesuada. Cras ultricies ligula sed magna dictum porta. Vivamus suscipit tortor eget felis porttitor volutpat. Donec rutrum congue leo eget malesuada.
              <br>Sed porttitor lectus nibh. Curabitur aliquet quam id dui posuere blandit. Pellentesque in ipsum id orci porta dapibus. Proin eget tortor risus. Vivamus magna justo, lacinia eget consectetur sed, convallis at tellus. Mauris blandit aliquet elit, eget tincidunt nibh pulvinar a. Nulla quis lorem ut libero malesuada feugiat. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
              <br>
              Mauris blandit aliquet elit, eget tincidunt nibh pulvinar a. Vivamus suscipit tortor eget felis porttitor volutpat. Quisque velit nisi, pretium ut lacinia in, elementum id enim. Vivamus magna justo, lacinia eget consectetur sed, convallis at tellus. Donec sollicitudin molestie malesuada. Cras ultricies ligula sed magna dictum porta. Vivamus suscipit tortor eget felis porttitor volutpat. Donec rutrum congue leo eget malesuada.
              <br>Sed porttitor lectus nibh. Curabitur aliquet quam id dui posuere blandit. Pellentesque in ipsum id orci porta dapibus. Proin eget tortor risus. Vivamus magna justo, lacinia eget consectetur sed, convallis at tellus. Mauris blandit aliquet elit, eget tincidunt nibh pulvinar a. Nulla quis lorem ut libero malesuada feugiat. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
            </p>
          </article>


        </div>
      </div>
    </div>









  </body>

</html>

JSFIDDLE https://jsfiddle.net/janie2000/pf3L4y1d/5/

Thank you so much.



from Recent Questions - Stack Overflow https://ift.tt/37TUZni
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation