无法正确堆叠伪元素

时间:2017-01-31 12:02:51

标签: html css pseudo-element

我试图用CSS制作一个箭头。我有把伪元素放在父元素下面的问题。我不知道我做错了什么,我认为z-index设置得当。



if(PHPExcel_Shared_Date::isDateTime($cellobj)) {
    //it's a date
} 

.down-arrow {
    display: block;
    position: relative;
    margin: 0 auto;
    width: 2px;
    height: 50px;
    background-color: #fbc52b;
    z-index: 100;
}

.down-arrow::before,
.down-arrow::after {
    content: "";
    display: block;
    position: absolute;
    width: 8px;
    height: 8px;
    bottom: 0;
    left: -3px;
    -webkit-transform: rotate(45deg);
    transform: rotate(45deg);
    z-index: 5;
}

.down-arrow::before {
    bottom: -3px;
    background-color: #fbc52b;
}
.down-arrow::after {
    background-color: #f9f9f9;
}




1 个答案:

答案 0 :(得分:2)

试试这个



.down-arrow {
    display: block;
    position: relative;
    margin: 0 auto;
    width: 2px;
    height: 50px;
    background-color: #fbc52b;
}

.down-arrow::before,
.down-arrow::after {
    content: "";
    display: block;
    position: absolute
}

.down-arrow::before {
    background-color: #fbc52b;
    width: 9px;
    height: 2px;
    bottom: 1px;
    transform: rotate(45deg);
    left: -7px;
}
.down-arrow::after {
    background-color: #fbc52b;
    width: 9px;
    height: 2px;
    bottom: 1px;
    transform: rotate(-45deg);
}

<span class="down-arrow"></span>
&#13;
&#13;
&#13;