gpt4 book ai didi

html - 无法设置适当的伪元素堆叠

转载 作者:太空宇宙 更新时间:2023-11-04 01:59:56 24 4
gpt4 key购买 nike

我正在尝试仅使用 CSS 制作箭头。我在将伪元素放在父元素下方时遇到问题。我不知道我做错了什么,我认为 z-index 设置正确。

.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;
}
<span class="down-arrow"></span>

最佳答案

试试这个

.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>

关于html - 无法设置适当的伪元素堆叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41957100/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com