【问题标题】:Best practice of css in Mui and Reactjs [closed]Mui 和 Reactjs 中 css 的最佳实践 [关闭]
【发布时间】:2023-01-03 00:53:14
【问题描述】:

我是 mui 的新手,请向我建议在 mui 组件中执行 CSS 的最佳方法

<Typography
    variant="h5"
    sx={{
      fontWeight: "bold",
      color: "#1a759f",
      display: "flex",
      justifyContent: "center",
      margin: "20vh",
    }}
   >
   Topology
</Typography>

我通常这样做 CSS 但不是内联 CSS,这不是一个好习惯

【问题讨论】:

  • 为什么这不是一个好习惯?

标签: javascript html css reactjs material-ui


【解决方案1】:

移动到一个变量

const styles = {

  typographyStyle: {
        fontWeight: "bold",
        color: "#1a759f",
        display: "flex",
        justifyContent: "center",
        margin: "20vh",
  },
};

在元素中

  sx={[styles.typographyStyle]}

【讨论】:

    猜你喜欢
    • 2012-03-05
    • 2020-12-06
    • 1970-01-01
    • 1970-01-01
    • 2013-10-02
    • 2010-10-06
    • 2011-10-28
    • 2010-09-10
    • 2011-10-11
    相关资源
    最近更新 更多