0

I have created a portfolio page for myself.

https://alonoparag.github.io/index.html#home

My problem is that when I check the page using Google Developers tools or with my android (samsung galaxy s4) device, the navbar's items are always behind the content of #home.

I tried tweaking the z index of the navbar items versus the home content, with no avail. When Checking the elements in the developer's tools I saw that both the navbar elements and the div z-index have changed, but it didn't affected the way that the elements are stacked.

I would appreciate help with this.

Cheers

here's my code

.topnav.responsive a {
   float: none;
   display: block;
   text-align: left;
   z-index: 10000;
}

div.content {
   align-content: center;
   width: 85%;
   margin: auto;
   padding: 16px;
   z-index: 1;
}

3 Answers 3

3

You have to give a position for z-index to work. So if you add position:relative; z-index:10; to your header, it should work fine.

Sign up to request clarification or add additional context in comments.

Comments

3

You have to specify a (static) position, for example.

position: relative;

or

position: fixed;

"z-index only effects elements that have a position value other than static (the default)." - https://css-tricks.com/almanac/properties/z/z-index/

1 Comment

I tried using your solution, but it didn't seem to solve the problem, even when each element is given a position other than static, they still stack over the navbar items.
2

The one issue I found is that the parent #home container itself seems to be the one giving you grief. Here are some tweaks I made in the developer console on my end. I tested it on a full desktop view as well as shrunk it down in the mobile preview and it worked properly.

CSS:

#home {
   z-index: 1;
}

#myTopnav {
   z-index: 999;
}

In addition, make sure to establish a position value for your elements.

That should do the trick for you!

1 Comment

That's just because he's set a position to the #myTopnav element. Using your answer he can fall into the same trap again next time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.