【发布时间】:2021-10-14 08:02:52
【问题描述】:
我已经设法使用以下方法从上到下实现了我想要做的事情:
/* I'm interested in filling with a solid color, but in order to partially fill the background, I seem to have to use a dummy gradient to make the color behave as an image */
.test {
width: 50px;
height: 100px;
border: 5px solid black;
background-image: linear-gradient(blue, blue);
background-size: 100% 50%;
background-repeat: no-repeat;
}
<div class="test"></div>
在这个例子中,有没有办法从下到上填充 div,使下半部分为蓝色,另一半为白色?
【问题讨论】:
-
@amirify 谢谢,基本上是的,与答案中给出的相比,我只需要改变渐变的角度
-
@TylerH 谢谢,这实际上是最适合我的特定需求的方法
-
@MikeKatz45 我将我的评论转换为答案;请看下文。