【发布时间】:2021-07-08 11:19:03
【问题描述】:
我正在尝试在我的表单中使用react-phone-input-2,因为它提供了许多功能,例如标志和格式化数字等。
但我无法使用自己的 css 自定义输入。例如:高度、宽度
我还导入了由同一个包提供的材料 css,因为我使用材料 ui 的所有其他组件。
import PhoneInput from 'react-phone-input-2';
import 'react-phone-input-2/lib/material.css';
<div>
<PhoneInput
country={'us'}
value={this.props.receiverPhone}
className={classes.phoneNumber}
fullWidth="true"
onChange={(phone) => this.props.changePhoneNumber(phone)}
/>
</div>
我的风格
phoneNumber: {
[theme.breakpoints.down('sm')]: {
width: '95%',
},
[theme.breakpoints.up('md')]: {
width: '93%',
},
[theme.breakpoints.up('lg')]: {
width: '82%',
},
padding: '5px',
height: '40px',
marginTop: theme.spacing(2),
marginRight: theme.spacing(1),
marginBottom: theme.spacing(3),
},
我也尝试将style={{width:100, height:40}} 和InputProps{{className:classes.phoneNumber}}作为道具提供给<PhoneInput>,但看起来即使这样也行不通。
有没有其他方法可以解决这个问题?
【问题讨论】:
标签: css reactjs redux material-ui