任务 1
在此任务中,第一个列表项已通过十六进制颜色代码设置了背景颜色。请使用相同颜色但不同格式的代码完成 CSS,并在最后一个列表项中使背景半透明。
- 第二个列表项应使用 RGB 颜色。
- 第三个列表项应使用 HSL 颜色。
- 第四个列表项应使用 RGB 颜色,但 alpha 通道设置为
0.6。
你可以在 convertingcolors.com 上转换十六进制颜色。你需要弄清楚如何在 CSS 中使用这些值。你的最终结果应该如下图所示。

html
<ul>
<li class="hex">hex color</li>
<li class="rgb">RGB color</li>
<li class="hsl">HSL color</li>
<li class="transparency">Alpha value 0.6</li>
</ul>
css
body {
font: 1.2em / 1.5 sans-serif;
}
ul {
list-style: none;
margin: 0;
padding: 0;
}
li {
margin: 1em;
padding: 0.5em;
}
.hex {
background-color: #86defa;
}
/* Add styles here */
任务 2
在此任务中,我们要你设置各种文本项的字体大小。
<h1>元素应为50px。<h2>元素应为2em。- 所有
<p>元素应为16px。 - 紧跟在
<h1>后面的<p>元素应为120%。
您的最终结果应如下面的图片所示

html
<h1>Level 1 heading</h1>
<p>
Veggies es bonus vobis, proinde vos postulo essum magis kohlrabi welsh onion
daikon amaranth tatsoi tomatillo melon azuki bean garlic.
</p>
<h2>Level 2 heading</h2>
<p>
Gumbo beet greens corn soko endive gumbo gourd. Parsley shallot courgette
tatsoi pea sprouts fava bean collard greens dandelion okra wakame tomato.
Dandelion cucumber earthnut pea peanut soko zucchini.
</p>
css
body {
font: 1.2em / 1.5 sans-serif;
}
h1 {
/* Add styles here */
}
h2 {
/* Add styles here */
}
p {
/* Add styles here */
}
h1 + p {
/* Add styles here */
}
点击此处显示解决方案
你可以使用以下长度值。
css
h1 {
font-size: 50px;
}
h2 {
font-size: 2em;
}
p {
font-size: 16px;
}
h1 + p {
font-size: 120%;
}
任务 3
要完成此任务,请更新 CSS,将背景图片移动到距离盒子顶部 20% 的位置,并使其水平居中。
您的最终结果应如下面的图片所示

html
<div class="box"></div>
css
.box {
border: 5px solid black;
height: 350px;
}
.box {
background-image: url("https://mdn.github.io/shared-assets/images/examples/purple-star.png");
background-repeat: no-repeat;
}
点击此处显示解决方案
使用 background-position 属性,并结合 center 关键字和一个百分比值。
css
.box {
background-image: url("https://mdn.github.io/shared-assets/images/examples/purple-star.png");
background-repeat: no-repeat;
background-position: center 20%;
}