From d62c168d0656fac4242581609c3c5c0d88cf6a48 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 29 一月 2021 18:03:47 +0800 Subject: [PATCH] 2021-01-29 --- src/components/Image/index.jsx | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/src/components/Image/index.jsx b/src/components/Image/index.jsx index e2a7989..01bd23e 100644 --- a/src/components/Image/index.jsx +++ b/src/components/Image/index.jsx @@ -26,7 +26,11 @@ let ratio = (width / height) / (clientWidth / clientHeight) - if (ratio > 1) { + if (ratio > 1.5) { + let _height = Math.floor(height * (clientWidth / width)) + this.ImageDom.style.height = 'auto' + this.ImageDom.style.top = ((clientHeight - _height) / 2) + 'px' + } else if (ratio > 1 && ratio < 1.5) { let _width = Math.floor(width / (height / clientHeight)) this.ImageDom.style.width = _width + 'px' this.ImageDom.style.left = '-' + ((_width - clientWidth) / 2) + 'px' -- Gitblit v1.8.0