首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >z-index属性不处理带有图像的容器。

z-index属性不处理带有图像的容器。
EN

Stack Overflow用户
提问于 2014-06-25 20:28:10
回答 2查看 2.6K关注 0票数 0

不知道我可能做错了什么,我试着这样说:

代码语言:javascript
复制
.container-image{
    background: url('http://i.imgur.com/Dl8UBO7.png');
    width: 226px;
    height: 169px;
    display: inline-block;
    position: relative;
    z-index: 20; // dont work
}

.container-image img{
    position: absolute;
    left: 14px;
    top: 13px;
    width: 199px;
    height: 141px;
    z-index: 10; // dont work
}

小提琴

我需要图像在边缘后面(容器-图像)

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-06-25 20:46:04

在边界div和图像周围放置一个容器。http://jsfiddle.net/7fqAu/2/

代码语言:javascript
复制
<div class='example'>
    <div class="container-image"></div>
    <img src="http://i.imgur.com/T0KMwIs.jpg">
</div>
代码语言:javascript
复制
body {
    background: red;
}
.container-image {
    background: url('http://i.imgur.com/Dl8UBO7.png');
    width: 226px;
    height: 169px;
    position: relative;
    z-index: 20;
}
.example {
    width: 226px;
    height: 169px;
    position: relative;
}
.example img {
    position: absolute;
    left: 14px;
    top: 13px;
    width: 199px;
    height: 141px;
    z-index: 10;
}
票数 0
EN

Stack Overflow用户

发布于 2014-06-25 20:51:19

您可以将边框图像添加到.container-image:after中,而不是作为.container-image的背景--那么根本不需要z索引。

小提琴手

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24417956

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档