如何用渐变色填充部分背景?

How to fill part of the background with gradient color?

我想要 div 填充颜色的背景:

如何定义第二个条件?

https://jsfiddle.net/tf4nn5p6/

这是你想要的吗?

.my-div{
  text-align: center;
  height: 50px;
  background-image: linear-gradient(to right, transparent, #FFEBEE);
  background-size: 100% 20%;
  background-position: left bottom;
  background-repeat: no-repeat;
  border: 1px solid red;
}
<div class='my-div'>
 text
</div>

使用下面的 css 相同,在这里您可以通过 background-size: 100% 20%;background-position 进行控制:左下角; 不重复

.my-div{
  height: 50px;
  background: linear-gradient(to right, transparent, #FFEBEE);
  background-size: 100% 20%;
  background-position: left bottom;
  background-repeat: no-repeat;
  border: 1px solid red;
  text-align: center;
}