简体   繁体   English

如何更改 index.html 中 body 的背景颜色?

[英]How can I change the background color of the body in index.html?

I'm new to Reactjs. I did some researches in google on how to change the background color of the body in index.html but nothing work.我是 Reactjs 的新手。我在谷歌上做了一些关于如何更改 index.html 中正文背景颜色的研究,但没有任何效果。 I have tried to use <style> tag in the <head> tag and I have also tried to create new style.css file in public folder and linked it to index.html but it changed nothing!我尝试在<head>标签中使用<style>标签,我也尝试在public文件夹中创建新的style.css文件并将其链接到index.html但它没有任何改变!

here is how I linked style.css to index.html <link href="%PUBLIC_URL%/style.css" rel="stylesheet"/>这是我如何将 style.css 链接到 index.html <link href="%PUBLIC_URL%/style.css" rel="stylesheet"/>

Please help!请帮忙! Thank before hand提前致谢

Update.更新。 When I refreshed the page the background color did change but only in around 0.001s then It went back to white.当我刷新页面时,背景颜色确实发生了变化,但仅在 0.001 秒左右,然后它又变回了白色。

For inline CSS you can try:对于内联 CSS,您可以尝试:

<body style="background-color:yellow;">
      <h1>Products</h1>
      <p>We have developed more than 10 products till now.</p>
 </body>

In your index.css , add:在您的index.css中,添加:

body {
  background-color: 'blue';
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM