我使用此代码将背景设为蓝色:
<!DOCTYPE html>
<html>
<body style="background-color:blue;">
</body>
</html>
哪种方法有效,但如何让背景有两种不同的颜色? 50%为蓝色,其余50%为黄色,例如水平分割......
答案 0 :(得分: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%);