use the css transform scale property to change the size of an element - zilongxuan001/LearnFreecode GitHub Wiki

使用CSS的transform scale属性改变元素的尺寸

理解

为改变元素的比例,CSS有transform属性和scale()功能。

下面例子是将原来<p>元素的尺寸在页面中放大两倍。

p {
   transform:scale(2);
}

练习

将id为ball2的元素的尺寸调整为1.5倍。

<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%;
    transform:scale(1.5);
    
  }


</style>

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

来源

Applied Visual Design: Use the CSS Transform scale Property to Change the Size of an Element | Learn freeCodeCamp

CHANGELOG

2018-10-30 15:03:46

⚠️ **GitHub.com Fallback** ⚠️