html - Z-Index 问题框

标签 html css

我有问题,对齐第 3 个框上的 div,结果如下所示。

a busy cat

HTML

<div class="hbox">

<div class="h1"></div>
    
    <div class="h2"></div>
    
    <div class="h3"></div>

</div>

CSS

.hbox
{
float: left;
width: 323px;
height: 188px;
margin: 88px 0 0 5px;
background:url("http://oi59.tinypic.com/96j3g0.jpg") no-repeat;
}

.h1
{float: left;
position: relative;
    width:62px;
    height:62px;
    border-radius:100%;
left: 79px;
top: 24px;
z-index: 2; background:#000;}

http://jsfiddle.net/1mmj24ny/

最佳答案

试试伪元素:before 他的代码DEMO

.hbox
{
float: left;
width: 323px;
height: 188px;
margin: 88px 0 0 5px;
background:url("http://oi59.tinypic.com/96j3g0.jpg") no-repeat;
    position:relative;
}

.hbox:before {
    background: none repeat scroll 0 0 #fff;
    content: "";
    height: 115px;
    left: 27px;
    position: absolute;
    top: 58px;
    width: 282px;
    z-index: 10;
}

.h1
{float: left;
position: relative;
    width:62px;
    height:62px;
    border-radius:100%;
left: 79px;
top: 24px;
z-index: 2; background:#000;}

.h2
{float: left;
position: relative;
    width:62px;
    height:62px;
    border-radius:100%;
left: 79px;
top: 24px;
z-index: 2; background:#ccc;}


.h3
{float: left;
position: relative;
    width:62px;
    height:62px;
    border-radius:100%;
left: 79px;
top: 24px;
z-index: 2; background:#ff0000;}

关于html - Z-Index 问题框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26038388/

相关文章:

html - CSS :hover image switch with child selectors

javascript - 网页编辑器,以便在我更新 JavaScript 和 HTML 时刷新页面

php - 文本框中的文本自动完成[内附图片]

java - 检查并插入缺少 alt 属性的图像

javascript - 使用嵌套单选按钮获取父输入 div 的 ID 以实现可访问性

HTML5 网络音频 seeTo 用于缓冲源

css - 如何删除 tailwindcss 中的背景色?

css - Bootstrap 和 gmaps4rails

html - 所有页面和元素样式上的 rgba

css - 我应该更改文件中的 css 样式还是原始文件中的样式