近日問題總結(二)

利用 background-size 做視覺差效果

body {
  height: 100vh;
  width: 100%;
}
#photo {
  position: fixed;
  top: 0;
  left: 0;
  z-index: -1;
  background: url(b9r5sEL.jpg) no-repeat;
  background-size: cover;
  height: 100%;
  width: 100%;
}

transform-origin()

transform-origin()的默認原點是center,也就是x軸和y軸的50%處。

在這裏插入圖片描述

實例

transform-origin取值爲top(或top center或center top或50% 0):
在這裏插入圖片描述

Array.from()

Array.from()方法用於將 類數組對象可遍歷對象 轉爲真正的數組。
類數組對象:本質特徵只有一點,既必須有length屬性。
可遍歷對象:有iterator接口的對象
    ~~~~
Array.from()一般使用一個參數,即要轉化的對象。第二個參數類似數組的map方法

<body>
  <div class="qwe">123</div>
  <div class="qwe">123</div>
  <div class="qwe">123</div>
  <script>
    let div = document.getElementsByClassName('qwe');
    let arr = Array.from(div, x => x.innerHTML + 1 )
    console.log(arr)
    /*結果(3) ["1231", "1231", "1231"]*/
  </script>
</body>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章