freeCodeCamp/curriculum/challenges/chinese/01-responsive-web-design/applied-visual-design/use-the-css-transform-scale...

1.6 KiB
Raw Blame History

id title challengeType videoUrl localeTitle
587d78a5367417b2b2512ad9 Use the CSS Transform scale Property to Change the Size of an Element 0 使用CSS Transform scale属性更改元素的大小

Description

要更改元素的比例CSS具有transform属性及其scale()函数。以下代码示例将页面上所有段落元素的大小加倍:
p {
变换比例2;
}

Instructions

使用ball2的id将元素的大小ball2原始大小的1.5倍。

Tests

tests:
  - text: '设置<code>#ball2</code>的<code>transform</code>属性将其缩放为其大小的1.5倍。'
    testString: 'assert(code.match(/#ball2\s*?{\s*?left:\s*?65%;\s*?transform:\s*?scale\(1\.5\);\s*?}|#ball2\s*?{\s*?transform:\s*?scale\(1\.5\);\s*?left:\s*?65%;\s*?}/gi), "Set the <code>transform</code> property for <code>#ball2</code> to scale it 1.5 times its size.");'

Challenge Seed

<style>
  .ball {
    width: 40px;
    height: 40px;
    margin: 50 auto;
    position: fixed;
    background: linear-gradient(
      35deg,
      #ccffff,
      #ffcccc
    );
    border-radius: 50%;
  }
  #ball1 {
    left: 20%;
  }
  #ball2 {
    left: 65%;

  }


</style>

<div class="ball" id= "ball1"></div>
<div class="ball" id= "ball2"></div>

Solution

// solution required