From cc75c9a083955a27f0048cacbc351f57efa10559 Mon Sep 17 00:00:00 2001 From: Hsuan Lee Date: Mon, 26 Nov 2018 17:27:28 +0800 Subject: [PATCH] fix(module:avatar): fix text style --- components/avatar/nz-avatar.component.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/components/avatar/nz-avatar.component.ts b/components/avatar/nz-avatar.component.ts index b3b94429bfa..da66df65c74 100644 --- a/components/avatar/nz-avatar.component.ts +++ b/components/avatar/nz-avatar.component.ts @@ -106,15 +106,13 @@ export class NzAvatarComponent implements OnChanges { const childrenWidth = this.textEl.nativeElement.offsetWidth; const avatarWidth = this.el.getBoundingClientRect().width; const scale = avatarWidth - 8 < childrenWidth ? (avatarWidth - 8) / childrenWidth : 1; - if (scale === 1) { - this.textStyles = {}; - } else { - this.textStyles = { - transform: `scale(${scale})`, - position : 'absolute', - display : 'inline-block', - left : `calc(50% - ${Math.round(childrenWidth / 2)}px)` - }; + this.textStyles = { + transform: `scale(${scale}) translateX(-50%)` + }; + if (typeof this.nzSize === 'number') { + Object.assign(this.textStyles, { + lineHeight: `${this.nzSize}px` + }); } this.cd.detectChanges(); }