• 0

Z-Index Voids Clickable Links


Question

So basically, no matter if I use <a> or <div> (with an onClick), z-index stops it from being clickable. I really don't understand the cause of this. Can anyone help me figure this out?

Link to comment
Share on other sites

14 answers to this question

Recommended Posts

  • 0

&lt;div onClick="location.href='#'" id="ad-bg"&gt;

#ad-bg {
width: 100%;
height: 100%;
background: #000 url(http://cdn.lolsomuch.com/img/cod-bg.jpg) no-repeat right top;
background-size: contain;
cursor: pointer;
position: fixed;
top: 0;
right: 0;
left: 0;
bottom: 0;
margin: auto;
z-index: -1;
}

Link to comment
Share on other sites

  • 0

A z-index of -1, will be rendered behind the BODY of your website (assuming your BODY element is using the default z-index of 0); this is why you're thinking you cannot click on the element.

Link to comment
Share on other sites

  • 0

Alright, but, does anyone happen to contain any knowledge on the code of the solution? I can't really wrap this around my head.

Link to comment
Share on other sites

  • 0

Code of what? We need to know what you're doing - so full code please.

But on what has been seen: z-index -1 is BEHIND everything else so it's not click-able because something is obscuring it.

Link to comment
Share on other sites

  • 0

it's worth explaining that just as you have the y and x axis controlling vertical and horizontal position, the z axis adds the third dimension allowing you to control layers through z-index

superstringgraphic3.jpg

Link to comment
Share on other sites

  • 0

<div onClick="location.href='#'" id="ad-bg">

#ad-bg {

width: 100%;

height: 100%;

background: #000 url(http://cdn.lolsomuch.../img/cod-bg.jpg) no-repeat right top;

background-size: contain;

cursor: pointer;

position: fixed;

top: ;

right: ;

left: ;

bottom: ;

margin: auto;

}

fixed

Go to Complex.com, if you notice the ads behind the content. That's what I'm trying to accomplish.

Link to comment
Share on other sites

  • 0

Sorry i caused you guys trouble. Here's the site http://lolsomuch.com. Go to one of the single posts & you'll notice the clickable background. That's what I'm trying to do, but I realized that i had to create a container for the page to be over 2 points at least and keep the clickable -1 so everything still overlaps the body.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.