Files
freeCodeCamp/curriculum/challenges/chinese/01-responsive-web-design/applied-visual-design/adjust-the-width-of-an-element-using-the-width-property.chinese.md

2.2 KiB
Raw Blame History

id, title, challengeType, videoUrl, forumTopicId, localeTitle
id title challengeType videoUrl forumTopicId localeTitle
587d7791367417b2b2512ab4 Adjust the Width of an Element Using the width Property 0 https://scrimba.com/c/cvVLPtN 301039 使用 width 属性调整元素的宽度

Description

你可以使用 CSS 里面的 width 属性来指定元素的宽度。属性值可以是相对单位(比如 em绝对单位比如 px或者包含块父元素宽度的百分比。下面这个例子把图片的宽度设置为 220px
img {
  width: 220px;
}

Instructions

给卡片添加 width 属性,设置它的宽度为 245px。使用 fullCard class 来选择元素。

Tests

tests:
  - text: '你应该使用 <code>fullCard</code> class 选择器将卡片的 <code>width</code> 宽度属性更改为 <code>245px</code>。'
    testString: 'assert(code.match(/.fullCard\s*{[\s\S][^}]*\n*^\s*width\s*:\s*245px\s*;/gm), ''你应该使用 <code>fullCard</code> class 选择器将卡片的 <code>width</code> 宽度属性更改为 <code>245px</code>。'');'

Challenge Seed

<style>
  h4 {
    text-align: center;
  }
  p {
    text-align: justify;
  }
  .links {
    margin-right: 20px;
    text-align: left;
  }
  .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>
      <p>Google 由在斯坦福大学攻读理工博士的拉里·佩奇和谢尔盖·布林共同创建。</p>
    </div>
    <div class="cardLinks">
      <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>
    </div>
  </div>
</div>

Solution

// solution required