jay*_*y.m 17 css reactjs material-ui
无线电组始终在材料-ui中列出.有没有办法水平对齐它们?例如,一条水平线上的所有单选按钮.
Hyd*_*ack 24
只需使用该row
属性:
<RadioGroup row><Radio /><Radio /></RadioGroup>
Run Code Online (Sandbox Code Playgroud)
RadioGroup继承自FormGroup,因此FormGroup组件的属性也可用.
lam*_*ris 23
要连续渲染单选按钮:
<RadioButtonGroup style={{ display: 'flex' }}>
Run Code Online (Sandbox Code Playgroud)
根据内容重置大小:
<RadioButton style={{ width: 'auto' }} />
Run Code Online (Sandbox Code Playgroud)
只需在 RadioGroup 控件上添加道具row={true} 即可。
<RadioGroup
aria-label="Location"
name="location"
className={classes.group}
value={location}
onChange={handleChange}
row={true}
>
<FormControlLabel value="company" control={<Radio />} label="Company" />
<FormControlLabel value="home" control={<Radio />} label="Home" />
<FormControlLabel value="other" control={<Radio />} label="Other" />
</RadioGroup>
Run Code Online (Sandbox Code Playgroud)
对于那些仍在挣扎中的人,请使用这种风格:
const styles = theme => ({
group: {
width: 'auto',
height: 'auto',
display: 'flex',
flexWrap: 'nowrap',
flexDirection: 'row',
}
});
class MyComponent extends React.Component {
render() {
const { classes } = this.props;
<RadioGroup className={classes.group} ...>
}
};
export default withStyles(styles)(MyComponent);
Run Code Online (Sandbox Code Playgroud)