简体   繁体   English

在 MUI 中对齐文本第二行

[英]Align text second line in MUI

I have a problem on aligning the texts on the second line.我在对齐第二行的文本时遇到问题。 It needs to be aligned with the first line.它需要与第一行对齐。

Codesandbox CLICK HERE Codesandbox 点击这里

<Card sx={{ maxWidth: 200 }}>
  <CardMedia
    component="img"
    height="140"
    image="/static/images/cards/contemplative-reptile.jpg"
    alt="green iguana"
  />
  <CardContent>
    <Typography gutterBottom variant="h5" component="div">
      Lizard
    </Typography>
    <Box>
      <Typography variant="body2" color="error">
        &bull; Hello how are you doing there?
      </Typography>
    </Box>
    <Box>
      <Typography variant="body2" color="error">
        &bull; Hi how are you doing there?
      </Typography>
    </Box>
  </CardContent>
  <CardActions>
    <Button size="small">Share</Button>
    <Button size="small">Learn More</Button>
  </CardActions>
</Card>

Please try using ul html element and add some styles.请尝试使用ul html 元素并添加一些 styles。

...
      <CardContent>
        <ul>
          <li>
            <Typography variant="body2" color="error">
              Hello how are you doing there?
            </Typography>
          </li>
          <li>
            <Typography variant="body2" color="error">
              Hi how are you doing there?
            </Typography>
          </li>
        </ul>
      </CardContent>
      ...

Put the bullet inside another Typography component and align it horizontally:将子弹放在另一个Typography组件中并水平对齐:

<Stack direction="row" gap={1}>
  <Typography variant="body2" color="error">
    &bull;
  </Typography>
  <Typography variant="body2" color="error">
    Hello how are you doing there?
  </Typography>
</Stack>

Before

在此处输入图像描述

After

在此处输入图像描述

Live Demo现场演示

Codesandbox 演示

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

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