第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何按比例調(diào)整圖像大小/保持高寬比?

如何按比例調(diào)整圖像大小/保持高寬比?

開心每一天1111 2019-07-27 16:56:50
如何按比例調(diào)整圖像大小/保持高寬比?我的圖像將是相當大的維度,我想縮小他們與jQuery,同時保持比例限制,即相同的縱橫比。有人能告訴我一些代碼,或者解釋一下邏輯嗎?
查看完整描述

3 回答

?
浮云間

TA貢獻1829條經(jīng)驗 獲得超4個贊

我覺得這真的是冷法:

 /**
  * Conserve aspect ratio of the original region. Useful when shrinking/enlarging
  * images to fit into a certain area.
  *
  * @param {Number} srcWidth width of source image
  * @param {Number} srcHeight height of source image
  * @param {Number} maxWidth maximum available width
  * @param {Number} maxHeight maximum available height
  * @return {Object} { width, height }
  */function calculateAspectRatioFit(srcWidth, srcHeight, maxWidth, maxHeight) {

    var ratio = Math.min(maxWidth / srcWidth, maxHeight / srcHeight);

    return { width: srcWidth*ratio, height: srcHeight*ratio };
 }




查看完整回答
反對 回復 2019-07-27
  • 3 回答
  • 0 關注
  • 1121 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號