使用 CSS 渐变。在您的情况下,CSS 将是:
background-image: linear-gradient(bottom, rgb(0,255,0) 50%, rgb(255,0,0) 50%);
background-image: -o-linear-gradient(bottom, rgb(0,255,0) 50%, rgb(255,0,0) 50%);
background-image: -moz-linear-gradient(bottom, rgb(0,255,0) 50%, rgb(255,0,0) 50%);
background-image: -webkit-linear-gradient(bottom, rgb(0,255,0) 50%, rgb(255,0,0) 50%);
background-image: -ms-linear-gradient(bottom, rgb(0,255,0) 50%, rgb(255,0,0) 50%);
background-image: -webkit-gradient(
linear,
left bottom,
left top,
color-stop(0.5, rgb(0,255,0)),
color-stop(0.5, rgb(255,0,0))
);
使用此站点生成更多:http://gradients.glrzad.com/