简体   繁体   English

如何避免排版中的换行

[英]How to avoid line break in Typography

I have a material ui Typography which is giving line break even though space is there, Below is the code我有一个材质 ui Typography ,即使有空格,它也会换行,下面是代码

  <Box flexDirection="row">
  <Typography>
    Gender:
    <RadioGroup
      row
      aria-label="gender"
      name="gender1"
      value={value}
      onChange={handleChange}
    >
      <FormControlLabel value="female" control={<Radio />} label="Female" />
      <FormControlLabel value="male" control={<Radio />} label="Male" />
      <FormControlLabel value="other" control={<Radio />} label="Other" />
    </RadioGroup>
  </Typography>
</Box>

How to display 'Gender' and 'Radio' buttons both in one row.如何在一行中显示“性别”和“收音机”按钮。 Here is my codesandbox Link这是我的代码和框链接

You can use Grid within Box您可以在 Box 中使用Grid

<Box flexDirection="row" >
      <Grid container direction="row"
      justify="space-evenly"
       alignItems="center">
         <Grid item>
           <Typography>
             Gender:
           </Typography>
         </Grid>
         <Grid item>
           <RadioGroup
              row
              aria-label="gender"
              name="gender1"
              value={value}
              onChange={handleChange}> 
             <FormControlLabel value="female" control={<Radio />} label="Female" />
             <FormControlLabel value="male" control={<Radio />} label="Male" />
             <FormControlLabel value="other" control={<Radio />} label="Other" />
           </RadioGroup>
         </Grid>
        </Grid>          
    </Box>

codesandbox link代码和框链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM