mint-ui icon indicating copy to clipboard operation
mint-ui copied to clipboard

Radio 组件选中后样式不居中

Open IssaTan1990 opened this issue 9 years ago • 4 comments

Mint UI version

^2.1.1

Device model

chrome 模拟器,及IOS 9.3 6.5.5版微信

What is actually happening?

在使用 Radio 这个组件时,选中的样式有偏差,如图

qq 20170223153915
我看了下radio 的样式代码

.mint-radio-core {
    display: inline-block;
    background-color: #fff;
    border-radius: 100%;
    border: 1px solid #ccc;
    position: relative;
    width: 20px;
    height: 20px;
    vertical-align: middle;
}
.mint-radio-core::after {
    content: " ";
    border-radius: 100%;
    top: 5px;
    left: 5px;
    position: absolute;
    width: 8px;
    height: 8px;
    -webkit-transition: -webkit-transform .2s;
    transition: -webkit-transform .2s;
    transition: transform .2s;
    transition: transform .2s, -webkit-transform .2s;
    -webkit-transform: scale(0);
            transform: scale(0);
}

其中外层 mint-radio-core 宽、高分别为20px,border 为 1px,也即整个core 为 宽高22px的正方形,而里面的 ::after 为宽高 8px的正方形,如果需要居中,top ,left 都应该为 6px 吧? (absolute 定位不包含 border) 但代码里面只有 5px,我查了下issue,好像没人提过这个问题?所以是因为我做了什么才会出现不居中吗?

IssaTan1990 avatar Feb 23 '17 07:02 IssaTan1990

你改了所有元素的box-sizing吧?

galenyuan avatar Feb 23 '17 09:02 galenyuan

@galenyuan 感谢。但我没有改过,box-sizing 的默认值应该是 content-box ?
我搜索了一下,.mint-cell-wrapper 和 .mint-cell 是有设置 box-sizing: border-box 的,但 .mint-radio-core 没有继承

qq 20170224185014

PS:我估计是因为我既没有用任何的reset.css 也没有用 normalize.css,但既然box-sizing 的默认值是 content-box ,.mint-radio-core 还是要声明一下

IssaTan1990 avatar Feb 24 '17 10:02 IssaTan1990

我用了normalize.css 也遇到同样的问题。P.S. 如果多提供几个icon就好了比如 check mark

ZhihaoLau avatar Mar 19 '17 07:03 ZhihaoLau

fixed in #740

galenyuan avatar Mar 23 '17 06:03 galenyuan