css - 图像的 Z-index 问题

标签 css

我有这个代码

.logo {
   display: block;
   z-index: 2;
}

.ellipse {
  background: red none repeat scroll 0 0;
  border-radius: 50%;
    left: 80px;
  height: 100px;
  margin: 0 0 0 -50px;
  position: absolute;
  width: 100px;
  top: 130px;
  z-index: 1;
}
<div class="bloc-logo">
    <div class="logo"><img src="http://1389blog.com/pix/happy-cat-wallpaper-thumbnail.jpg" width="150" height="150" alt="fff" /></div>
    <div class="ellipse"></div>
</div>

我希望图像位于圆形 div 之上。我尝试使用 z-index,但它不起作用。

谢谢你的帮助!

最佳答案

在 .ellipse 上将 z-index 设置为 -1。请参阅提供的代码笔和相关代码。

.ellipse {
  background: red none repeat scroll 0 0;
  border-radius: 50%;
    left: 80px;
  height: 100px;
  margin: 0 0 0 -50px;
  position: absolute;
  width: 100px;
  top: 130px;
  z-index: -1;
}

http://codepen.io/Billy-Purvis/pen/oXEEaM

关于css - 图像的 Z-index 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31187254/

相关文章:

javascript - 在谷歌地图中滑动 div

html - 我需要所有这些包裹吗?

css - 填充、边距和转换值是否有限制?

javascript - 使用jquery访问另一个类中的类

css - ipad 纵向 View 中的背景图像正在缩小

html - 如何更改 Bootstrap 3 中一行的颜色?

html - 将段落与 FontAwesome 图标对齐

html - 导航栏在 IE6、7、8 中显示不佳,但适用于 9 和所有其他浏览器

javascript - 切换 CSS 类对元素没有影响

css - div 中的持久文本标题 (CSS)