此页面需较新浏览器(支持 SharedArrayBuffer)。请升级 Chrome、Edge、Firefox 或 Safari 至最新版本。
颜色
- 你可以用名字写颜色:
red、blue、green、tomato、gold等等。 - 或使用像
#2a7ae2这样的十六进制代码——由一个#后跟六个十六进制数字组成(0–9和a–f)。 - 名字好记;十六进制代码能给你数百万种精确的颜色。
背景
color改变文字的颜色。background-color改变元素背后的颜色。- 把
background-color写在body上,就能给整个页面上色。
English
<style>
body { background-color: #f3f4f6; }
h1 { color: tomato; }
</style>
<h1>Hello!</h1>
<p>A page with a soft grey background.</p>
常见错误
color设文字;background-color设背景。- 颜色可以是名字、
#rrggbb码或rgb(...)。
现在轮到你
color是文字,background-color是它背后的颜色。- 先给页面背景上色,再用十六进制颜色给标题上色。
难度 2/5 · 今日首次完成可获 140 金币及少量额外奖励
Give the whole page a soft background. Add body { background-color: lightyellow; }.
难度 2/5 · 今日首次完成可获 140 金币及少量额外奖励
Colour the heading with a hex code. Add h1 { color: #2a7ae2; } (that's a blue).
难度 2/5 · 今日首次完成可获 140 金币及少量额外奖励
Colours can be mixed from red, green and blue. Give the heading the colour rgb(0, 128, 0), and the page the background #f0f8ff.