【问题标题】:Css not updating react componentCSS不更新反应组件
【发布时间】:2020-08-07 07:53:33
【问题描述】:
   /* Here is my container in my react component */
   <Container fluid className="graph-container">
      <Tabs
        id="graph-buttons"
        variant={"pills"}
      >
        <Tab id="line-tab" eventKey="line" title="Line">
          <Content greeting={"line"} />
        </Tab>
        <Tab id="bar-tab" eventKey="otherline" title="OtherLine">
          <Content greeting={"bar"} />
        </Tab>
        <Tab id="doughnut-tab" eventKey="doughnut" title="Doughnut">
          <Content greeting={"doughnut"} />
        </Tab>
      </Tabs>
    </Container>

 /* Here is my CSS for the above component */
.graph-container{
  background: black;
}

#graph-buttons{
  margin-top: 50px;
}

#line-tab{
  font-family: 'Courier New', Courier, monospace;
  color: red;
  background: red;
}

.graph-container 正在使用 CSS 进行更改,但由于某种原因,CSS 未与选项卡部分内的任何内容链接。这可能是什么原因?感谢您的帮助!

【问题讨论】:

    标签: javascript css reactjs react-bootstrap


    【解决方案1】:

    &lt;Container&gt; 正在覆盖您指定的样式。 您可以尝试在样式后添加!important,如下所示:

    .graph-container{
      background: black !important;
    }
    

    或者尝试添加内联样式,如下所示:

    <Container fluid style={{background: 'black'}}>
      <Tabs
        id="graph-buttons"
        variant={"pills"}
      >
        <Tab id="line-tab" eventKey="line" title="Line">
          <Content greeting={"line"} />
        </Tab>
        <Tab id="bar-tab" eventKey="otherline" title="OtherLine">
          <Content greeting={"bar"} />
        </Tab>
        <Tab id="doughnut-tab" eventKey="doughnut" title="Doughnut">
          <Content greeting={"doughnut"} />
        </Tab>
      </Tabs>
    </Container>
    

    希望这会有所帮助。让我知道它是否有效。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-05-25
      • 2016-01-19
      • 1970-01-01
      • 2017-07-30
      • 2019-06-05
      • 2020-01-24
      • 2017-09-10
      • 2021-05-19
      相关资源
      最近更新 更多