dar*_*onz 2 html css background-color
我使用此代码将背景设为蓝色:
<!DOCTYPE html>
<html>
<body style="background-color:blue;">
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
哪个效果很好,但是如何使背景具有两种不同的颜色?例如,50% 为蓝色,其余 50% 为黄色,水平分割......
使用 css 渐变:https : //css-tricks.com/css3-gradients/
background: linear-gradient(blue, yellow);
Run Code Online (Sandbox Code Playgroud)
或者,如果您不想逐渐淡入淡出,则必须设置位置:
background: linear-gradient(to right, blue 0%, blue 50%, yellow 50%, yellow 100%);
Run Code Online (Sandbox Code Playgroud)