css - 将 Material UI 按钮放置在行的最右侧

标签 css reactjs material-ui

尝试将此 React Material-ui 按钮与页面的最右侧对齐,但似乎无法正常工作:

    <Grid item justify="flex-end">
      <Button              
        variant="contained"
        color="primary"
        onClick={() => myFunction()}
      >
        Submit
      </Button>
    </Grid>

已尝试 justify="flex-end" 但似乎不起作用。

最佳答案

这段代码对我有用。

<Box display="flex" justifyContent="flex-end">
  <Button              
    variant="contained"
    color="primary"
    onClick={() => myFunction()}
  >
    Submit
  </Button>
</Box>

如果你想使用Grid,请使用这样的内联样式。

 <Grid item style={{display:"flex"}} justify="flex-end">
          <Button              
            variant="contained"
            color="primary"
            onClick={() => myFunction()}
          >
            Submit
          </Button>
</Grid>

关于css - 将 Material UI 按钮放置在行的最右侧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66978843/

相关文章:

javascript - 在 React 和 Redux 中创建动态按钮

javascript - react : passing parent state to child when the parent state is sourced and modified from external classes acting as a property in the parent

reactjs - onBlur 从子元素调用

reactjs - react Material 用户界面 : How to give a button a custom color when disabled?

javascript - 用于更改背景的 ajax 脚本在 IE 中不起作用

javascript - 单击链接时如何复制网页的这一部分?

reactjs - Materialise-CSS 和 Material UI 之间的区别

javascript - 如何测试使用 Material UI makeStyles() 制作的条件样式?

html - 最后一个 div 和最后一列的边距

html - 可调整大小的 DIV 内的流体图像