2016-05-28 177 views
0

你好,我有一個我正在創建的網站。我在添加背景之前使用過的背景上有文字和按鈕。但現在他們不再工作了。他們被吸引到屏幕但不起作用。看看這段代碼一分鐘:Html和CSS按鈕不起作用

<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> 

當按鈕在div rect0之外,那麼它們的功能,但是,當他們都在裏面,他們是不能點擊。這是影響它的css包裝。

#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; 

    } 

我在做什麼錯誤,不允許按鈕被激活?謝謝 - 傑克。

+0

我需要看到真人版確認div,但我猜這是因爲'的z指數:-1'。你有鏈接嗎? – darrylyeo

回答

0

刪除z-index: -1使其起作用。請參閱此Fiddle作爲參考。

由於您的按鈕全部位於div之內,因此您將其應用於z-index: -1;,這些按鈕也都會被推入背景中,因此被禁用。

0

#rect0上的負z-index將容器div推到其父「後面」。嘗試將其更改爲01

1

您正在設置一個負值z-index,將div移動到主層後面。以下圖片顯示了z-index如何工作。頁面上的所有內容,例如你的身體有預設z-index: 0,通過設置z-index: -1要移動/渲染背後的body

enter image description here