gpt4 book ai didi

html - 两个伪元素::before 具有不同的属性

转载 作者:行者123 更新时间:2023-11-28 04:09:17 27 4
gpt4 key购买 nike

使用了两个伪元素 ::before与不同border属性(参见 js fiddle)。尽管“您只能使用一个 ::before 和一个 ::after 伪元素”,但它确实有效。为什么?

https://jsfiddle.net/8L7zou3e/1/

<div class="el"></div>

.el {
position: relative;
margin: 100px 0 0 500px;
width: 300px;
height: 100px;
background-color: #AA4343;
}
.el:before {
content: '';
display: inline-block;
width: 0;
height: 0;
border-top: 50px solid #e86d0a;
border-left: 50px solid transparent;
position: absolute;
top: 0;
left: -50px;
}

.el:before {
content: '';
display: inline-block;
width: 0;
height: 0;
border-bottom: 50px solid #e86d0a;
border-left: 50px solid transparent;
position: absolute;
top: 0px;
left: -50px;
}

最佳答案

你好像只有一个伪元素。

cons

在 UI 中:

pseudo

您的 CSS 级联到:

.el:before {
content: '';
display: inline-block;
width: 0;
height: 0;
border-top: 50px solid #e86d0a;
border-left: 50px solid transparent;
position: absolute;
border-bottom: 50px solid #e86d0a;
border-left: 50px solid transparent;
top: 0;
left: -50px;
}

查看 Chrome 处理组合 CSS 的方式:

chrome treatment

关于html - 两个伪元素::before 具有不同的属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47333953/

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