2018-10-10 22:03:03 +00:00
|
|
|
|
---
|
|
|
|
|
id: 587d7791367417b2b2512ab3
|
|
|
|
|
challengeType: 0
|
2020-02-11 07:46:34 +00:00
|
|
|
|
videoUrl: 'https://scrimba.com/c/c3b4EAp'
|
|
|
|
|
forumTopicId: 301053
|
2020-10-01 15:54:21 +00:00
|
|
|
|
title: 使用 text-align 属性创建视觉平衡
|
2018-10-10 22:03:03 +00:00
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## Description
|
2020-02-11 07:46:34 +00:00
|
|
|
|
<section id='description'>
|
|
|
|
|
这部分课程主要关于应用视觉设计。开始的挑战展示了一些核心的原则,代码基于一个指定的卡片布局。
|
|
|
|
|
web 内容大部分都是文本。CSS 里面的 <code>text-align</code> 属性可以控制文本的对齐方式。
|
|
|
|
|
<code>text-align: justify;</code> 可以让除最后一行之外的文字两端对齐,即每行的左右两端都紧贴行的边缘。
|
|
|
|
|
<code>text-align: center;</code> 可以让文本居中对齐。
|
|
|
|
|
<code>text-align: right;</code> 可以让文本右对齐。
|
|
|
|
|
<code>text-align: left;</code> 是 <code>text-align</code> 的默认值,它可以让文本左对齐。
|
|
|
|
|
</section>
|
2018-10-10 22:03:03 +00:00
|
|
|
|
|
|
|
|
|
## Instructions
|
2020-02-11 07:46:34 +00:00
|
|
|
|
<section id='instructions'>
|
|
|
|
|
居中对齐 <code>h4</code> 标签文本,文本内容为 “Google”。两端对齐段落标签文本,文本介绍了 Google 的创立。
|
|
|
|
|
</section>
|
2018-10-10 22:03:03 +00:00
|
|
|
|
|
|
|
|
|
## Tests
|
|
|
|
|
<section id='tests'>
|
|
|
|
|
|
|
|
|
|
```yml
|
|
|
|
|
tests:
|
2020-02-11 07:46:34 +00:00
|
|
|
|
- text: '你应该在 <code>h4</code> 标签上使用 text-align 属性设置文本居中对齐。'
|
2020-02-17 16:40:55 +00:00
|
|
|
|
testString: assert($('h4').css('text-align') == 'center');
|
2020-02-11 07:46:34 +00:00
|
|
|
|
- text: '你应该在 <code>p</code> 标签上使用 text-align 属性设置文本两端对齐。'
|
2020-02-17 16:40:55 +00:00
|
|
|
|
testString: assert($('p').css('text-align') == 'justify');
|
2018-10-10 22:03:03 +00:00
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
## Challenge Seed
|
|
|
|
|
<section id='challengeSeed'>
|
|
|
|
|
|
|
|
|
|
<div id='html-seed'>
|
|
|
|
|
|
|
|
|
|
```html
|
|
|
|
|
<style>
|
|
|
|
|
h4 {
|
2020-02-11 07:46:34 +00:00
|
|
|
|
|
2018-10-10 22:03:03 +00:00
|
|
|
|
}
|
|
|
|
|
p {
|
2020-02-11 07:46:34 +00:00
|
|
|
|
|
2018-10-10 22:03:03 +00:00
|
|
|
|
}
|
|
|
|
|
.links {
|
|
|
|
|
margin-right: 20px;
|
2020-02-11 07:46:34 +00:00
|
|
|
|
|
2018-10-10 22:03:03 +00:00
|
|
|
|
}
|
|
|
|
|
.fullCard {
|
|
|
|
|
border: 1px solid #ccc;
|
|
|
|
|
border-radius: 5px;
|
|
|
|
|
margin: 10px 5px;
|
|
|
|
|
padding: 4px;
|
|
|
|
|
}
|
|
|
|
|
.cardContent {
|
|
|
|
|
padding: 10px;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
<div class="fullCard">
|
|
|
|
|
<div class="cardContent">
|
|
|
|
|
<div class="cardText">
|
|
|
|
|
<h4>Google</h4>
|
2020-02-11 07:46:34 +00:00
|
|
|
|
<p>Google 由在斯坦福大学攻读理工博士的拉里·佩奇和谢尔盖·布林共同创建。</p>
|
2018-10-10 22:03:03 +00:00
|
|
|
|
</div>
|
|
|
|
|
<div class="cardLinks">
|
2020-02-11 07:46:34 +00:00
|
|
|
|
<a href="https://en.wikipedia.org/wiki/Larry_Page" target="_blank" class="links">拉里·佩奇</a>
|
|
|
|
|
<a href="https://en.wikipedia.org/wiki/Sergey_Brin" target="_blank" class="links">谢尔盖·布林</a>
|
2018-10-10 22:03:03 +00:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
## Solution
|
|
|
|
|
<section id='solution'>
|
|
|
|
|
|
2020-02-11 07:46:34 +00:00
|
|
|
|
```html
|
2018-10-10 22:03:03 +00:00
|
|
|
|
// solution required
|
|
|
|
|
```
|
2020-02-11 07:46:34 +00:00
|
|
|
|
|
2018-10-10 22:03:03 +00:00
|
|
|
|
</section>
|
2020-02-11 07:46:34 +00:00
|
|
|
|
|