4.7 KiB
4.7 KiB
id | title | required | challengeType | videoUrl | localeTitle | |||||
---|---|---|---|---|---|---|---|---|---|---|
bad87fee1348bd9aedd08845 | Add Font Awesome Icons to our Buttons |
|
0 | 添加字体真棒图标到我们的按钮 |
Description
.svg
文件格式存储。这些图标就像字体一样对待。您可以使用像素指定其大小,并且它们将采用其父HTML元素的字体大小。您可以在任何应用程序中包含Font Awesome,方法是在HTML的顶部添加以下代码: <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" integrity="sha384-XdYbMnZ/QjLh6iI4ogqCTaIjrFk87ip+ekIjefZch0Y+PvJ8CDYtEs1ipDmPorQ+" crossorigin="anonymous">
在这种情况下,我们已经在幕后为您添加了这个页面。 i
元素最初用于使其他元素斜体,但现在通常用于图标。您可以将Font Awesome类添加到i
元素以将其转换为图标,例如: <i class="fa fa-info-circle"></i>
请注意, span
元素也可用于图标。使用Font Awesome将一个thumbs-up
图标添加到你喜欢的按钮,给它一个带有fa
和fa-thumbs-up
类的i
元素;确保在图标旁边保留“赞”字样。 Instructions
Tests
tests:
- text: 使用<code>fa</code>和<code>fa-thumbs-up</code>类添加<code>i</code>元素。
testString: 'assert($("i").is(".fa.fa-thumbs-up") || $("span").is(".fa.fa-thumbs-up"), "Add an <code>i</code> element with the classes <code>fa</code> and <code>fa-thumbs-up</code>.");'
- text: 您的<code>fa-thumbs-up</code>图标应位于Like按钮内。
testString: 'assert(($("i.fa-thumbs-up").parent().text().match(/Like/gi) && $(".btn-primary > i").is(".fa.fa-thumbs-up")) || ($("span.fa-thumbs-up").parent().text().match(/Like/gi) && $(".btn-primary > span").is(".fa.fa-thumbs-up")), "Your <code>fa-thumbs-up</code> icon should be located within the Like button.");'
- text: 将您的<code>i</code>元素嵌套在<code>button</code>元素中。
testString: 'assert($("button").children("i").length > 0 || $("button").children("span").length > 0, "Nest your <code>i</code> element within your <code>button</code> element.");'
- text: 确保您的图标元素具有结束标记。
testString: 'assert(code.match(/<\/i>|<\/span>/g), "Make sure your icon element has a closing tag.");'
Challenge Seed
<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<style>
h2 {
font-family: Lobster, Monospace;
}
.thick-green-border {
border-color: green;
border-width: 10px;
border-style: solid;
border-radius: 50%;
}
</style>
<div class="container-fluid">
<div class="row">
<div class="col-xs-8">
<h2 class="text-primary text-center">CatPhotoApp</h2>
</div>
<div class="col-xs-4">
<a href="#"><img class="img-responsive thick-green-border" src="https://bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying on its back."></a>
</div>
</div>
<img src="https://bit.ly/fcc-running-cats" class="img-responsive" alt="Three kittens running towards the camera.">
<div class="row">
<div class="col-xs-4">
<button class="btn btn-block btn-primary">Like</button>
</div>
<div class="col-xs-4">
<button class="btn btn-block btn-info">Info</button>
</div>
<div class="col-xs-4">
<button class="btn btn-block btn-danger">Delete</button>
</div>
</div>
<p>Things cats <span class="text-danger">love:</span></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>
<form action="/submit-cat-photo">
<label><input type="radio" name="indoor-outdoor"> Indoor</label>
<label><input type="radio" name="indoor-outdoor"> Outdoor</label>
<label><input type="checkbox" name="personality"> Loving</label>
<label><input type="checkbox" name="personality"> Lazy</label>
<label><input type="checkbox" name="personality"> Crazy</label>
<input type="text" placeholder="cat photo URL" required>
<button type="submit">Submit</button>
</form>
</div>
Solution
// solution required