Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Body text goes over the top of fixed nav bar

Tags:

html

css

I have a fixed nav bar, that follows when scrolling.

But upon scrolling over text/images within tags it seems to go in front of the navbar, rather then behind.

Why is this? How can I fix it?

Fiddle

nav {
  background-color: #262626;
  height: 60px;
  width: 100%;
  position: fixed;
  top: 0;
  bottom: 0;
  -webkit-box-shadow: 0px 0px 8px 0px #000000;
  -moz-box-shadow: 0px 0px 8px 0px #000000;
  box-shadow: 0px 0px 8px 0px #000000;
}
nav a {
  font-family: 'Open Sans', sans-serif;
  font-size: 16px;
  line-height: 60px;
  text-transform: uppercase;
  margin: 7px;
}
nav a:link {
  color: #C8C8C8;
  -o-transition: .5s;
  -ms-transition: .5s;
  -moz-transition: .5s;
  -webkit-transition: .5s;
  transition: .5s;
}
nav a:visited {
  color: #C8C8C8;
}
nav a:hover {
  color: #199ABA;
}
#menu {
  margin-right: 375px;
  margin-left: 375px;
  text-align: right;
  margin-top: 0px;
  margin-bottom: 0px;
}
#headertop {
  margin: 0px;
  width: 100%;
  height: 650px;
  font-family: 'Open Sans', sans-serif;
}
#headertop h1 {
  position: absolute;
  margin-left: 375px;
  margin-right: 375px;
  margin-top: 178px;
  line-height: 45px;
  font-size: 50px;
  color: #33CCFF;
  width: 550px;
  height: 100%;
}
<nav>
  <div id="menu">
    <strong><a href="index.html" style="text-decoration:none">Home</a></strong>
  </div>
</nav>
<div id="headertop">
  <h1>THANKS</h1>
</div>
like image 354
Spaccee Avatar asked Jun 23 '15 08:06

Spaccee


2 Answers

This is usually caused by your z-index, make sure you put:

CSS

z-index: 500 // or whatever number that is a positive real number.

Yep, I was right, see this DEMO.

like image 124
ARLCode Avatar answered Sep 21 '22 11:09

ARLCode


nav {
    background-color: #262626;
    height: 60px;
    z-index:1; //any higher integer value
    width: 100%;
    position: fixed;
    top: 0;
    bottom: 0;
    -webkit-box-shadow: 0px 0px 8px 0px #000000;
    -moz-box-shadow: 0px 0px 8px 0px #000000;
    box-shadow: 0px 0px 8px 0px #000000;
}

Refer z-index in W3Schools also Refer CSS-Tricks

like image 34
RevanthKrishnaKumar V. Avatar answered Sep 19 '22 11:09

RevanthKrishnaKumar V.