圖片等比例縮放方案

export const aspectRatio = (width, height) => {io

  height: 0,di

  overflow: 'hidden',co

  paddingBottom: `${(height / width) * 100}%`,asp

}const

 

padding-bottom 值爲百分比時,百分比與其所在元素的父元素的寬度相關。

相關文章
相關標籤/搜索