2017-08-04 71 views
-1

有兩個div塊。第一個有z-index: 0,另一個有z-index: -1。如何在z-index: -1塊中的所有內容上顯示文本。我把文字樣式cursor: pointer兩個div塊z索引

.first-block image as pizza { 
    display: inline-block; 
    position: relative; 
    z-index: 700; 
} 

#second block when circle has some text { 
    position: absolute; 
    top: -15%; 
    right: -20%; 
    z-index: -1; 
} 

#text div { 
    position: absolute; 
    top: 50%; 
    left: 50%; 
    transform: translate(-50%, -50%); 
    width: 90%; 
    text-align: center; 
    display: inline-block; 
} 

enter image description here

+1

能否請您分享您的相關HTML和CSS? –

+0

@VadimOvchinnikov是 –

+0

@VadimOvchinnikov 。第一塊圖像比薩餅{ display:inline-block; 位置:相對; z-index:700; } #second block when circle has some text { position:absolute; top:-15%; 右:-20%; z-index:-1; } #text div { position:absolute; top:50%; 剩餘:50%; transform:translate(-50%,-50%); 寬度:90%; text-align:center; display:inline-block; } –

回答

1

如果我沒有理解好你的要求,你應該嘗試做同樣的事情。 如果您在問題中發佈您的HTML和CSS代碼,我們可以幫助您更好! :)

/*image as pizza*/ 
.first-block { 
    display: inline-block; 
    position: relative; 
    z-index: 700; 
} 

/*block when circle has some text*/ 
#second { 
    position: absolute; 
    top: -15%; 
    right: -20%; 
    /*z-index: -1;I suggest you to remove this one, as it would be under the pizza anyway, because pizza have z-index 700.*/ 
} 

/*div*/ 
#text { 
    position: absolute; 
    top: 50%; 
    left: 50%; 
    transform: translate(-50%, -50%); 
    width: 90%; 
    text-align: center; 
    display: inline-block; 
    z-index: 701; /*And add here(The DIV in which your text is nested) the z-index*/ 
} 

編輯:

<div class="first-block">img of pizza under the text but over the circle.<div> 
<div id="second"> <!--This is the circle divin which the text is nested.--> 
    <div id="text"> 
    SOME TEXT OVER THE PIZZA'S IMAGE. 
    </div> 
<div> 
+0

它的工作原理!但我需要的是兩個塊必須在一個div塊=)。 –

+0

我已經編輯了更好的顯示結構的答案:) –