在 React-Bootstrap 中定义 CSS 文件的位置?
Where to define CSS files in React-Bootstrap?
为 class 定义自定义 css 让我感到困惑。
React-Bootstrap 文档说,您可以使用 bsClass
.
定义自定义非 bootstrap 样式
但是,这是我的疑问:-
- 我们是否需要在条目 html 页面中包含自定义样式表 link?
- 如果不是,那么节点环境如何能够识别 css 文件位于何处?
how is node environment able to recognize where are the css files located?
您需要手动将其添加到您的页面。
一种方法(如果您使用 webpack
并安装了 css-loader
插件,react-create-app
默认情况下)是将您的 .css 文件包含在一个需要特定样式表的组件:
import './mystylesheet.css'
因此您的组件将如下所示:
import React from 'react'
import { Button } from 'react-bootstrap'
import './mystylesheet.css'
export default function MyCustomButton(props) {
return <Button bsClass="my-custom-class">My button</Button>
}
为 class 定义自定义 css 让我感到困惑。
React-Bootstrap 文档说,您可以使用 bsClass
.
但是,这是我的疑问:-
- 我们是否需要在条目 html 页面中包含自定义样式表 link?
- 如果不是,那么节点环境如何能够识别 css 文件位于何处?
how is node environment able to recognize where are the css files located?
您需要手动将其添加到您的页面。
一种方法(如果您使用 webpack
并安装了 css-loader
插件,react-create-app
默认情况下)是将您的 .css 文件包含在一个需要特定样式表的组件:
import './mystylesheet.css'
因此您的组件将如下所示:
import React from 'react'
import { Button } from 'react-bootstrap'
import './mystylesheet.css'
export default function MyCustomButton(props) {
return <Button bsClass="my-custom-class">My button</Button>
}