我正在尝试创建一个自定义input
,它可以是 typeradio
或checkbox
. 但是我在 IE 浏览器上遇到了 CSS 的问题。
预期结果:
IE浏览器结果
输入 JSX
const CheckBox2: FC<ICheckBox2Props> = ({ label, type = "checkbox", className, labelClassName, ...props }) => {
return (
<label className={[styles.container, className ?? ""].join(" ")}>
<input
{...props}
type={type}
/>
{label && <span className={[styles.label, labelClassName ?? ""].join(" ")} >{label}</span>}
</label>
);
};
export default CheckBox2;
输入 CSS
.container {
display: inline-flex;
align-items: center;
margin-right: 48px;
>input {
cursor: pointer;
height: 17px;
width: 17px;
box-sizing: border-box;
border: 1px solid #ABACAD;
border-radius: 2px;
-webkit-appearance: none;
-moz-appearance: none;
-ms-appearance: none;
-o-appearance: none;
appearance: none;
outline: none;
&:checked {
height: 17px;
width: 17px;
box-sizing: border-box;
border: 1px solid #2D3641;
border-radius: 2px;
background-color: #2D3641;
background-image: url(../../../../assets/images/icons/ico_check.png);
background-size: 10px 9px;
background-repeat: no-repeat;
background-position: center;
}
}
.label{
margin-left: 16px;
}
}
慕哥9229398
MMTTMM
相关分类