Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css Div未出现在前面:Z-Index_Css_Z Index - Fatal编程技术网

Css Div未出现在前面:Z-Index

Css Div未出现在前面:Z-Index,css,z-index,Css,Z Index,我正在使用下面的代码,但是。under并没有上升到#portfolio_content.img img,因为它应该在上悬停 #portfolio_wrap { overflow:hidden; width:980px; float:left } #portfolio_content { float:left; clear:both; margin:0 auto; overflow:hidden; width:650px!import

我正在使用下面的代码,但是
。under
并没有上升到
#portfolio_content.img img
,因为它应该在
上悬停

#portfolio_wrap {
    overflow:hidden;
    width:980px;
    float:left
}
#portfolio_content {
    float:left;
    clear:both;
    margin:0 auto;
    overflow:hidden;
    width:650px!important
}
#portfolio_content ul {
    list-style:none
}
#portfolio_content .img a { }
#portfolio_content .img a:hover { }
#portfolio_content .img {
    display:block;
    float:left;
    height:210px;
    margin:0 35px 35px 0!important;
    overflow:hidden;
    padding:0;
    width:307px
}
#portfolio_content .img img {
    display:block;
    position:absolute!important;
    overflow:hidden;
    z-index:3!important
}
#portfolio_content .img .title, #portfolio_content .img .title a {
    font-size:22px;
    margin:100px 0 10px 0;
    float:left!important;
    width:307px;
    text-align:center;
    position:relative
}
.desc {
    font-size:13px;
    display:block;
    text-align:center!important;
    margin:0 auto!important;
    width:307px
}
.under {
    z-index:2!important;
    display:inline;
    position:absolute;
    width:307px;
    height:210px
}
.under:hover { z-index:4!important }

有什么想法吗?我假设这与z-index有关,但我不知道我做错了什么。

在没有看到呈现的页面的情况下,我不得不假设问题是您不能将鼠标悬停在
。在
下(
z-index:2
),因为它隐藏在
公文包内容下。img img
z-index:3
)最初,因此您将只悬停在
img
上。

在没有看到呈现的页面的情况下,我不得不假设问题是您实际上无法悬停在
上。
下(
z-index:2
),因为它隐藏在
公文包内容下。img img
z-index:3
)最初,因此您只能将鼠标悬停在
img
上。

您不能将鼠标悬停在
上。
下,因为它总是“在”您的图像下,所以tw16是正确的

不要玩z索引,试着将
放在
.img
内的
下,但放在图像的顶部,并使用
显示:无
,然后执行以下操作:

.img:hover .under{
    display:block;
} 
我可能会补充说,您的标记没有得到充分优化,
.img
应该直接放在
a
标记上,而不是放在无用的
span
s内部,反正这些标记太多了:)

编辑:(作为对评论的回答)

如果没有图像显示,您的标记将与有图像显示时不同(例如,您不会回显
img
标记)。 您还可以使用该条件编写两个不同的类,例如
.img
.no-img

.no-img .under{
    display:block;
}

.img .under{
    display:none;
}

.img:hover .under{
    display:block;
}

您不能将鼠标悬停在
上方。在
下方,因为它总是在图像下方,所以tw16是正确的

不要玩z索引,试着将
放在
.img
内的
下,但放在图像的顶部,并使用
显示:无
,然后执行以下操作:

.img:hover .under{
    display:block;
} 
我可能会补充说,您的标记没有得到充分优化,
.img
应该直接放在
a
标记上,而不是放在无用的
span
s内部,反正这些标记太多了:)

编辑:(作为对评论的回答)

如果没有图像显示,您的标记将与有图像显示时不同(例如,您不会回显
img
标记)。 您还可以使用该条件编写两个不同的类,例如
.img
.no-img

.no-img .under{
    display:block;
}

.img .under{
    display:none;
}

.img:hover .under{
    display:block;
}

对不起,我看到不是这样的=)你能发布你的HTML吗?Thx.创建一个可能会有帮助。在看到你的JSFIDLE后,我会说@tw16的答案是正确的。对不起,我看到不是case=)你能发布你的HTML吗?Thx.创建一个可能会有帮助。在看到您的JSFIDLE之后,我会说@tw16的答案是正确的。另外,id class元素的指定度比class高,如果@tw16也这么说,那么idk,但这将覆盖一个简单的class声明。因此id class元素的指定度比class高,如果@tw16也这么说,那么idk,但是这将覆盖一个简单的类声明。这个解决方案的问题是,当没有图像()时,我仍然需要显示标题。不过,感谢您指出了跨度,并对其进行了修复。此解决方案的问题在于,当没有图像时,我仍然需要显示标题()。不过,谢谢你指出跨度,修复它。