【问题标题】:ReactJS Material UI inkbar not appearing for tabsReactJS Material UI 墨水栏没有出现在选项卡中
【发布时间】:2016-07-30 00:47:05
【问题描述】:

由于某种原因,小墨条不会出现在此选项卡下,它可能是 CSS 的东西,但我无法弄清楚,可能缺少一些我也不知道的东西,我一直在拉我的头发掉了,但我认为标签高度可能太高了?我不确定是否诚实,正在寻求帮助。

_getTabs() {


  let styles = {
      root: {
        backgroundColor: '#333',
        position: 'fixed',
        height: 64,
        top: 0,
        right: 0,
        zIndex: 0,
        width: '100%',
      },
      container: {
        position: 'absolute',
        right: (Spacing.desktopGutter/2) + 48,
        bottom: 0,
      },
      span: {
        color: white,
        left: 65,
        top: 18,
        position: 'absolute',
        fontSize: 26,
      },
      svgLogoContainer: {
        position: 'fixed',
        width: 300,
        left: Spacing.desktopGutter,
      },
      svgLogo: {
        width: 65,
        height: 65,
        backgroundColor: '#333',
        position: 'absolute',
        top: 0,
      },
      tabs: {
        width: 600,
        bottom:0,
        height: 64
      },
      tab: {
        height: 64,
        backgroundColor: '#333'
      },

    };
    let renderedResult;
    let loggedIn = false
    let materialIcon = this.state.tabIndex !== '0' ? (
     <EnhancedButton
        style={styles.svgLogoContainer}
        href="/">
        <span style={styles.span}>MobaRedux</span>
      </EnhancedButton>) : null;

    if (loggedIn) {
    renderedResult = (

        <Paper zDepth={0}
             rounded={false}
             style={styles.root}
        >

      {materialIcon}

          <div style={styles.container}>
            <Tabs
              style={styles.tabs}
              value={this.state.tabIndex}
              onChange={this._handleTabChange}
              inkBarStyle={{backgroundColor:"#FFC107"}}>
              <Tab
                value="8"
                label="DASHBOARD"
                style={styles.tab}/>
                <Tab
                value="5"
                label="ABOUT"
                style={styles.tab} />
            </Tabs>


          </div>

        </Paper>


    );
}

else {
  renderedResult = (

        <Paper zDepth={0}
             rounded={false}
             style={styles.root}
        >

            {materialIcon}

          <div style={styles.container}>
            <Tabs
              style={styles.tabs}
              value={this.state.tabIndex}
              onChange={this._handleTabChange}
              inkBarStyle={{backgroundColor:"#FFC107"}}>
              <Tab
                value="8"
                label="DASHBOARD"
                style={styles.tab}
                 />
                <Tab
                value="5"
                label="ABOUT"
                style={styles.tab}
                />
            </Tabs>


          </div>

        </Paper>

    );
}
return (
      <div>
        {renderedResult}
      </div>

    );
}

下面的蓝色标签是我只是在测试这些标签是否能正常工作

【问题讨论】:

  • 似乎是这样,它的 this._handleTabChange,用于移除墨条的选项卡的 onChange 属性,尚不知道为什么。

标签: css reactjs material-ui


【解决方案1】:

我可以通过修改 styles.root 的 z-index 来解决这个问题。您不应该在 position: fixed 元素上使用 z-index: 0 ,因为它只会在其他元素下消失。

      root: {
    backgroundColor: '#333',
    position: 'fixed',
    height: 64,
    top: 0,
    right: 0,
    zIndex: 1000, // Here is what i've changed to get it fixed
    width: '100%',
  },

【讨论】:

  • 我试过了,结果不是问题,实际上是我尝试的第一件事,也许它可能在其他地方
  • 看我的评论,似乎 onactive on change 是负责任的
猜你喜欢
  • 2018-08-12
  • 2021-03-23
  • 2015-10-24
  • 2018-12-21
  • 1970-01-01
  • 2021-04-04
  • 1970-01-01
  • 2021-04-21
  • 1970-01-01
相关资源
最近更新 更多