有两个div块。第一个有z-index: 0
,另一个有z-index: -1
。如何在z-index: -1
的块中的所有内容上显示文本。我输入了文字样式cursor: pointer
。
.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;
}
答案 0 :(得分: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>