CSS三角形填充进度条

Sha*_*llo 2 css html5 svg css3 css-shapes

我实际上用Google搜索并搜索了一些信息,但找不到它.

我的目标是实现类似于进度条样式的东西,例如填充三角形内部.有什么办法吗?填充

的jsfiddle

.angle {
    width: 0; 
    height: 0; 
    border-left: 75px solid transparent;
    border-right: 75px solid transparent;       
    border-bottom: 75px solid black;
}
Run Code Online (Sandbox Code Playgroud)

jbu*_*483 10

为了制作三角形,我会使用两个伪元素来"切掉"方形div.然后,使用嵌套div,使用绝对定位允许您将其"填充"到某个值(通过.amount以%为单位设置div的高度).

.amount {
  position: absolute;
  height: 0%;
  width: 100%;
  bottom: 0;
  left: 0;
  transition: all 1s;
  background: tomato;
}
.tri {
  position: relative;
  height: 200px;
  width: 200px;
  background: lightgray;
}
.tri:before,
.tri:after {
  content: "";
  position: absolute;
  border-top: 200px solid white;
  top: 0;
  z-index: 8;
}
.tri:before {
  border-left: 100px solid transparent;
  left: 50%;
}
.tri:after {
  border-right: 100px solid transparent;
  left: 0;
}
.tri:hover .amount {
  height: 100%;
}
Run Code Online (Sandbox Code Playgroud)
<div class="tri">
  <div class="amount"></div>
</div>
Run Code Online (Sandbox Code Playgroud)