Files
freeCodeCamp/curriculum/challenges/chinese/01-responsive-web-design/basic-css/size-your-images.md
2020-09-29 22:09:05 +02:00

2.7 KiB
Raw Blame History

id, title, challengeType, videoUrl, forumTopicId, localeTitle
id title challengeType videoUrl forumTopicId localeTitle
bad87fee1348bd9acdf08812 Size Your Images 0 https://scrimba.com/c/cM9MmCP 18282 调整图片的大小

Description

CSS 的width属性可以控制元素的宽度。图片的width宽度类似于字体的px(像素)值。 假如,你想创建一个叫larger-image的 CSS class 来控制 HTML 元素的宽度为 500px我们可以这样做
<style>
  .larger-image {
    width: 500px;
  }
</style>

Instructions

创建一个smaller-image的 CSS class设置图片的宽度为 100px。 注意:
由于不同浏览器的差异性,你可能需要将浏览器缩放到 100% 来通过该挑战。

Tests

tests:
  - text: '<code>img</code>元素应该含有<code>smaller-image</code> class。'
    testString: assert($("img[src='https://bit.ly/fcc-relaxing-cat']").attr('class') === "smaller-image");
  - text: '图片宽度应为 100px像素且浏览器缩放应为默认 100%。'
    testString: assert($("img").width() === 100);

Challenge Seed

<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<style>
  .red-text {
    color: red;
  }

  h2 {
    font-family: Lobster, monospace;
  }

  p {
    font-size: 16px;
    font-family: monospace;
  }
</style>

<h2 class="red-text">CatPhotoApp</h2>
<main>
  <p class="red-text">点击查看更多<a href="#">猫图</a>.</p>
  
  <a href="#"><img src="https://bit.ly/fcc-relaxing-cat" alt="一只仰卧着的萌猫"></a>
  
  <div>
    <p>猫咪最喜欢的三件东西:</p>
    <ul>
      <li>猫薄荷</li>
      <li>激光笔</li>
      <li>千层饼</li>
    </ul>
    <p>猫咪最讨厌的三件东西:</p>
    <ol>
      <li>跳蚤</li>
      <li>打雷</li>
      <li>同类</li>
    </ol>
  </div>
  
  <form action="https://freecatphotoapp.com/submit-cat-photo">
    <label><input type="radio" name="indoor-outdoor">室内</label>
    <label><input type="radio" name="indoor-outdoor">室外</label><br>
    <label><input type="checkbox" name="personality">忠诚</label>
    <label><input type="checkbox" name="personality">懒惰</label>
    <label><input type="checkbox" name="personality">积极</label><br>
    <input type="text" placeholder="猫咪图片地址" required>
    <button type="submit">提交</button>
  </form>
</main>

Solution

// solution required

/section>