【问题标题】:MuiPrivateTabScrollButton overwite the width and flex property in cssMui PrivateTabScrollButton 覆盖css中的width和flex属性
【发布时间】:2019-01-23 20:17:02
【问题描述】:
  • 我正在尝试覆盖 MuiPrivateTabScrollButton 的 css。
  • 但是这个类是从材料 ui 生成的,所以我无法覆盖。
  • 即使我通过设置边框颜色进行了调试并找到了修复方法,但我仍然无法找到。
  • 我所有的代码都在 tab-demo.js
  • 能否告诉我如何修复它,以便我以后自己修复它。
  • 在下面提供我的代码 sn-p 和沙箱

https://codesandbox.io/s/n5l8znn2y0

更新 1:删除不必要的代码以便于调试 https://codesandbox.io/s/8xw88yl9j0

MuiPrivateTabScrollButton: {
width: "0 !important"
},

tabRoot: {
    textTransform: "initial",
    width: "stretch",
    display: "flex",
    flex: 1,
    border: "1px solid red",

    "&:hover": {
      color: "red",
      opacity: 1,
      textTransform: "initial"
    },
    "&$tabSelected": {
      color: "red",
      fontWeight: theme.typography.fontWeightMedium,
      textTransform: "capitalize"
    },
    "&:focus": {
      color: "red",
      textTransform: "capitalize"
    }
  },

【问题讨论】:

  • 您的 CodeSandbox 应包含在您的问题中显示特定问题所需的最少数量。
  • @RyanCogswell 嘿,我更新了代码,你现在能帮帮我吗:(

标签: html css reactjs material-ui


【解决方案1】:

在每个 Material-UI 组件的文档中都有一个 CSS 部分,指示可以传入的类以控制不同方面的 CSS。 Here is that documentation for Tabs.

你特别关心:

scrollButtons 应用于 ScrollButtonComponent 组件的样式。

然后您需要通过classes 属性指定适当的类。

例如,如果您在传递给withStyles 的样式中有以下内容:

const styles = theme => ({

  tabsScrollButton: {
    backgroundColor: "green"
  }
};

然后您可以像下面这样利用该类:

<Tabs
   classes={{ scrollButtons: props.classes.tabsScrollButton }}
>

【讨论】:

  • 嘿,非常感谢,因为您为其他问题提供了否定掩码...我无法进一步发布:(
猜你喜欢
  • 2019-07-25
  • 2018-03-06
  • 2015-02-03
  • 2013-12-16
  • 1970-01-01
  • 2015-04-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多