0

Hello I have a website that I am making. I have text and buttons over a background that used to work before the background was added. But now they no longer work. They are drawn to the screen but do not function. Look at this code for a minute:

 <div id = "rect0">

    <div class = "banner grid_18" href="about.html">
    </div>
     <a href="logic.html"  class="button" id ="new">View Article</a>

    <div class=" grid_8 callout">
    </div>
     <a href="gallery.html"  class="button" id ="new1">View Gallery</a>


 </div>

When the buttons are outside the div rect0 then they function but when they are inside they are not clickable. Here's the css encase that is effecting it.

#rect0{
position: relative;
margin-top: -10px;
margin-left: 0px;
    width: 951px;
height: 270px;
padding-left: 4px;
padding-top: 1px;
background: #ffffff;
z-index: -1;
}

.button{
background: #242324;
color: #B7B7B7;
padding: 6px;
color: white;
font-size: 11px;
text-transform: uppercase;
 }

.button:hover{color: #d2d2d2;}

  #new{
position: absolute;
margin-left: -140px;
margin-top: 220px;
  }

  #new1{
position: absolute;
margin-left: 117px;
margin-top: 220px;

  }

What am I doing wrong that doesn't allow the buttons to be activated? Thanks - Jack.

1
  • I'd need to see the live version to confirm, but I'm guessing it's because of z-index: -1. Do you have a link? Commented May 28, 2016 at 17:51

3 Answers 3

1

You are setting a negative z-index which moves the div behind the main layer. The following pictures shows how the z-index works. Everything on the page, e.g. your body by default have z-index: 0, by setting z-index: -1 you are moving/rendering the div behind the body

enter image description here

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

Comments

0

Removing z-index: -1 makes it work. See this Fiddle as reference.

Since your buttons are all inside the div you apply z-index: -1; to they all get pushed into the background as well and are therefore disabled.

Comments

0

The negative z-index on #rect0 is pushing the container div "behind" its parent. Try changing it to 0 or 1

Comments

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.