【发布时间】:2020-07-19 12:42:19
【问题描述】:
我正在尝试创建一个自定义input,它可以是radio 或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;
}
}
【问题讨论】:
标签: javascript css reactjs typescript internet-explorer