javascript - React 在 Body 上设置样式

标签 javascript reactjs

如何在 React 功能组件中为 HTML Body 添加样式。我已将其包含在 css 中。我看到其他 CSS 正在被应用。但缺少车身样式

body { 
  height: 100% ;
  display:flex;
  flex-direction:column;
  justify-content: center;
}

enter image description here

最佳答案

您可以在public/index.html中添加此样式
您还忘记在 css 中的 body 后面添加冒号。

索引.html

<!DOCTYPE html>
<html lang="en">

<head>
   <style>
       body:{ 
          height: 100% ;
          display:flex;
          flex-direction:column;
          justify-content: center;
       }
   </style>
</head>

<body>
  <noscript>You need to enable JavaScript to run this app.</noscript>
  <div id="root"></div>
</body>

</html>

关于javascript - React 在 Body 上设置样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61606367/

相关文章:

reactjs - 如何使用 i18next 为不同的语言设置不同的字体?

html - 使用html中的react组件作为html标签

javascript - 无法在 Phonegap 中的 HTML5 Canvas 上绘制图像

javascript - HTML & CSS 视频样式

javascript - 表达 "Cannot GET/query"错误

javascript - 计算并定义具有特定 ID 前缀的输入数量

css - Ant design v4 中如何动态切换主题?

reactjs - ReferenceError : window is not defined. 当我通过 jest 运行 npm test 进行单元测试时出现此错误

javascript - setInterval时间不精确

javascript - 测试带有函数的 React Components setState 重载