Max Frai
Max Frai

Reputation: 64276

Relative positioning with z-index

I have 2 divs. Second is under first.

enter image description here

2nd div has z-index: -1; top: -20px; position: relative. Now I want to put some links(a-tag) into 2nd div: <a href="#">test</a>. Now I see my link but it's inactive. I can't click at it. When I remove z-index: -1 it works. What's wrong?

Upvotes: 1

Views: 952

Answers (1)

Justus Romijn
Justus Romijn

Reputation: 16019

A negative z-index can behave buggy. I would give the top div a higher z-index. You can better have something like this:

div.1 {
  position: relative;
  z-index: 3;
}
div.2 {
  position: relative;
  top: -20px
}

You're links should be clickable, if they are visible of course.

Upvotes: 2

Related Questions