简体   繁体   English

样式标准 reactjs 项目

[英]styling standard reactjs project

I have created a react project by npx create-react-app my-app .我通过npx create-react-app my-app创建了一个反应项目。

There are App.css and index.css in src folder of project.项目src文件夹下有App.cssindex.css I want to style my index.js project but neither of css files are responsible.我想为我的index.js项目设置样式,但 css 文件都不负责。

What are those files for and how can I globally style my project?这些文件的用途是什么?我如何全局设计我的项目?

What are those files for这些文件是做什么用的

Don't know不知道

how can I globally style my project?我如何全局设计我的项目?

import a css file in index.js在 index.js 中导入一个 css 文件

// index.js
import './somecssfile.css'

...

What are those files for?这些文件是做什么用的?

When you use CRA (create-ract-app), the app.css & index.css files are there to style the basic react app you get with the CTA template.当您使用 CRA (create-ract-app) 时,app.css 和 index.css 文件用于设置您使用 CTA 模板获得的基本 React 应用程序的样式。 I know the naming is a bit confusing.我知道命名有点混乱。 Check this issue on CRA github board: Misleading css files检查 CRA github 板上的这个问题: Misleading css files

how can I globally style my project?我如何全局设计我的项目?

To style your app there are lots of ways: CSS Modules, styled-compoment (my fav ourite)... check out this great article: 5 Ways to style your react app有很多方法可以为您的应用程序设置样式:CSS 模块、样式化组件(我最喜欢的)...查看这篇很棒的文章: 5 种设置 React 应用程序样式的方法

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

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