2017-04-12 203 views
1

我用这个代码,以使背景蓝色:HTML背景的两种颜色

<!DOCTYPE html> 
<html> 
<body style="background-color:blue;"> 
</body> 
</html> 

其中一期工程不错,但我怎样才能使背景有两种不同的颜色? 50%是蓝色的,其余50%是黄色的,例如,水平分割...

+0

请看看到http://www.css3factory.com/linear-gradients/ –

+0

找到答案在CSS做两个背景颜色[Ckick这里(HTTP:/ /stackoverflow.com/questions/19081355/how-can-apply-multiple-background-color-to-one-div) – codePhree

回答

3

使用CSS梯度:https://css-tricks.com/css3-gradients/

background: linear-gradient(blue, yellow); 

或者,如果你想不想的逐渐淡去你必须设置位置:

background: linear-gradient(to right, blue 0%, blue 50%, yellow 50%, yellow 100%);