freeCodeCamp/curriculum/challenges/chinese/01-responsive-web-design/applied-visual-design/adjust-the-height-of-an-ele...

2.1 KiB
Raw Blame History

id title challengeType videoUrl forumTopicId localeTitle
587d7791367417b2b2512ab5 Adjust the Height of an Element Using the height Property 0 https://scrimba.com/c/cEDaDTN 301034 使用 height 属性调整元素的宽度

Description

width 属性类似,你可以使用 CSS 里面的 height 属性来指定元素的高度。下面这个例子把图片的高度设置为 20px
img {
  height: 20px;
}

Instructions

h4 标签添加 height 属性并设置值为 25px。 注意: 可能需要将浏览器的缩放比调整为 100% 才能通过这一挑战。

Tests

tests:
  - text: '你应该设置 <code>h4</code> 的 <code>height</code> 属性,使其值为 <code>25px</code>。'
    testString: assert(Math.round(document.querySelector('h4').getBoundingClientRect().height) === 25 && /h4{\S*height:25px(;\S*}|})/.test($('style').text().replace(/\s/g ,'')));

Challenge Seed

<style>
  h4 {
    text-align: center;
    
  }
  p {
    text-align: justify;
  }
  .links {
    margin-right: 20px;
    text-align: left;
  }
  .fullCard {
    width: 245px;
    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