4.0 KiB
4.0 KiB
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
bad87fee1348bd9aedf08807 | Import a Google Font | 0 | 导入Google字体 |
Description
Lobster
字体。为此,请复制以下代码段并将其粘贴到代码编辑器的顶部(在开始style
元素之前): <link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
现在,您可以使用Lobster
作为FAMILY_NAME在CSS中使用Lobster
字体,如下例所示: font-family: FAMILY_NAME, GENERIC_NAME;
。 GENERIC_NAME是可选的,如果其他指定的字体不可用,则为后备字体。这将在下一个挑战中得到体现。系列名称区分大小写,如果名称中有空格,则需要用引号括起来。例如,您需要引号才能使用"Open Sans"
字体,但不能使用Lobster
字体。 Instructions
Lobster
字体的font-family
CSS规则,并确保它将应用于您的h2
元素。 Tests
tests:
- text: 导入<code>Lobster</code>字体。
testString: 'assert(new RegExp("googleapis", "gi").test(code), "Import the <code>Lobster</code> font.");'
- text: 你的<code>h2</code>元素应该使用字体<code>Lobster</code> 。
testString: 'assert($("h2").css("font-family").match(/lobster/i), "Your <code>h2</code> element should use the font <code>Lobster</code>.");'
- text: 使用<code>h2</code> CSS选择器更改字体。
testString: 'assert(/\s*h2\s*\{\s*font-family\:\s*(\"|")?Lobster(\"|")?\s*;\s*\}/gi.test(code), "Use an <code>h2</code> CSS selector to change the font.");'
- text: 你的<code>p</code>元素仍然应该使用字体<code>monospace</code> 。
testString: 'assert($("p").css("font-family").match(/monospace/i), "Your <code>p</code> element should still use the font <code>monospace</code>.");'
Challenge Seed
<style>
.red-text {
color: red;
}
p {
font-size: 16px;
font-family: monospace;
}
</style>
<h2 class="red-text">CatPhotoApp</h2>
<main>
<p class="red-text">Click here to view more <a href="#">cat photos</a>.</p>
<a href="#"><img src="https://bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying on its back."></a>
<div>
<p>Things cats love:</p>
<ul>
<li>cat nip</li>
<li>laser pointers</li>
<li>lasagna</li>
</ul>
<p>Top 3 things cats hate:</p>
<ol>
<li>flea treatment</li>
<li>thunder</li>
<li>other cats</li>
</ol>
</div>
<form action="/submit-cat-photo">
<label><input type="radio" name="indoor-outdoor" checked> Indoor</label>
<label><input type="radio" name="indoor-outdoor"> Outdoor</label><br>
<label><input type="checkbox" name="personality" checked> Loving</label>
<label><input type="checkbox" name="personality"> Lazy</label>
<label><input type="checkbox" name="personality"> Energetic</label><br>
<input type="text" placeholder="cat photo URL" required>
<button type="submit">Submit</button>
</form>
</main>
Solution
// solution required