Skip to content

Commit 640249c

Browse files
authored
fix: 修复关闭icon没有垂直居中的bug (#173)
1 parent ae2cf70 commit 640249c

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

packages/devui-vue/devui/tag/src/hooks/use-class.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import { tagProps, TagProps } from '../tag-types'
33

44
export default function (props: TagProps) {
55
return computed(() => {
6-
const { type, color } = props
7-
return `devui-tag devui-tag-${type || (color ? 'colorful' : '') || 'default'}`
6+
const { type, color, deletable } = props
7+
return `devui-tag devui-tag-${type || (color ? 'colorful' : '') || 'default'} ${
8+
deletable ? 'devui-tag-deletable' : ''
9+
}`
810
})
911
}

packages/devui-vue/devui/tag/src/tag.scss

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ $devui-tag-normal-config: (
2828
),
2929
colorful: (
3030
background-color: #fff
31+
),
32+
deletable: (
33+
padding-right: 32px
3134
)
3235
);
3336

@@ -48,7 +51,7 @@ $devui-tag-normal-config: (
4851
position: relative;
4952
cursor: default;
5053

51-
@each $type in default, primary, success, warning, danger, colorful {
54+
@each $type in default, primary, success, warning, danger, colorful, deletable {
5255
&.devui-tag-#{$type} {
5356
@each $key, $value in map-get($devui-tag-normal-config, $type) {
5457
#{$key}: $value;
@@ -66,8 +69,12 @@ $devui-tag-normal-config: (
6669
line-height: 12px;
6770
border-radius: 50%;
6871
text-align: center;
69-
position: relative;
70-
top: -0.22em;
71-
vertical-align: middle;
72+
position: absolute;
73+
top: 50%;
74+
transform: translateY(-50%);
75+
i {
76+
/* 取消icon自带的偏移 */
77+
vertical-align: 0;
78+
}
7279
}
7380
}

0 commit comments

Comments
 (0)