Home > Web Front-end > JS Tutorial > How to introduce styles in react

How to introduce styles in react

coldplay.xixi
Release: 2020-12-02 17:32:20
Original
9601 people have browsed it

How to introduce styles in react: 1. Module style, introduction method [import './index.css';]; 2. Inline style, the code is [].

How to introduce styles in react

Related learning recommendations: react video tutorial

The operating environment of this tutorial: windows7 system , React17 version, this method is suitable for all brands of computers.

How to introduce styles in react:

1. Module style

When you first build the framework, When I am about to start writing business, I will encounter the problem of how to introduce styles on the first page. I have encountered some pitfalls. Instead of using style, there is no need to name the header. Just introduce css directly. The introduction method is like this.

<div className=&#39;topHead back fs14&#39;>
     <img src=&#39;/images/highLevel.png&#39; className=&#39;levelSize&#39;/>
</div>
Copy after login

Use the form of className

Introduction method

import &#39;./index.css&#39;;
Copy after login

index.css

@import &#39;~antd/dist/antd.css&#39;;
.topHead {
    width: 100%;
    height: 100px;
    display: flex;  
    align-items: center;
}
.back{
    background-image: url(&#39;/images/homeBackImg.png&#39;);
}
.levelSize{
    width: 80px;
    height: 80px; 
}
.levelColor{
    color:#ffffff;
}
Copy after login

2. Inline style

The inline style is different from the usual style='margin:0px', so

 <Divider style={{margin:&#39;0px&#39;}}/>
也是用的style,但书写方式不一样了
Copy after login

Related free learning recommendations: javascript (video)

The above is the detailed content of How to introduce styles in react. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template