我正在创建一些 CSS 插图,我想创建一个三角形。但是,您会看到透明边框实际上并不透明。它与 的背景色具有相同的颜色<div>。
.triangle {
background-color: #ff3e30;
height: 0px;
width: 0px;
border-bottom: 100px solid #ff3e30;
border-left: 50px solid transparent; /* This is the culprit */
}
<div class="triangle"></div>
但是,当我使用不同的颜色时,如果边框是透明的,则表明创建的形状应该是三角形。
.triangle {
background-color: #ff3e30;
height: 0px;
width: 0px;
border-bottom: 100px solid #ff3e30;
border-left: 50px solid black; /* Changed to black */
}
<div class="triangle"></div>
那么,如何解决呢?