【问题标题】:Style <body> and <html> from React?样式 <body> 和 <html> 来自 React?
【发布时间】:2016-05-10 18:26:56
【问题描述】:

我可以像这样在 reactJS 中设置组件样式

        const buttonStyle = {
            marginTop: "10px"
        };

<button class="btn btn-block btn-success" style={buttonStyle}>Success</button>

我想从一个组件中更改正文标签,而不是从其他组件中更改。

这不起作用(因为正文在 index.html 中)

<body style={bodyStyle}>

我该怎么做?

【问题讨论】:

  • 为什么不在CSS 中定义呢?
  • stackoverflow.com/questions/25474803/…,不过,我也建议在 CSS 中定义它。
  • 如果我想在渲染一个页面/组件而不是其余页面/组件时在 上使用 css,我该如何在 CSS 中定义它?

标签: javascript html css reactjs


【解决方案1】:

react-body-classname 可用于将主体 style 修改为任何其他反应组件。

【讨论】:

    猜你喜欢
    • 2021-08-05
    • 1970-01-01
    • 2020-04-26
    • 2016-10-05
    • 1970-01-01
    • 2015-12-19
    • 2018-10-18
    • 1970-01-01
    • 2018-06-18
    相关资源
    最近更新 更多