<div class="box" style="width:120px"></div>

<div class="box" style="width:80px"></div>
.box {
  height:50px;
  margin:10px;
  background:
   linear-gradient(green,green) 0 /max(0px,100px - 100%) 1px,
   red;
}
/*
 I am using "linear-gradient(green,green) instead of linear-gradient(green 0 0) 
 for better browser support "
*/

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.