首页 > 解决方案 > 使用 makeStyles 的 MUI className 不应用 css 实现,但 style 呢?

问题描述

我在这里有我的代码,'DisplayPage'useStyle 中的宽度不起作用。但是,当我应用 style={{width: calc(100% - ${drawerWidth}px)}} 时,它开始工作。对某些人来说它可以工作,但在某些情况下它们不起作用,这很令人困惑。不太确定要实现哪些样式的因素是什么?

我如何知道何时会应用 makeStyles?

const drawerWidth = 240;

// MUI Setting
const useStyles = makeStyles((theme) => ({
  displayPage: {
    [theme.breakpoints.up('sm')]: {
      marginLeft: drawerWidth,
      height: `100%`,
      width: `calc(100% - ${drawerWidth}px)`,
    },
    [theme.breakpoints.up('xs')]: {
      width: '100%',
      height: `calc(100% - 64px)`,
    },
  },
}));

      <div
        className={classes.displayPage}
        style={{ width: `calc(100% - ${drawerWidth}px)` }}
      >


export default connect(mapStateToProps, mapDispatchToProps)(App);

标签: cssreactjsmaterial-ui

解决方案


推荐阅读