Detailed explanation of using style binding in React
May 24, 2018 pm 02:24 PMThis time I will bring you a detailed explanation of the use of style binding in React. What are the precautions when using style binding in React. The following is a practical case, let's take a look.
Use common style names—— className
app.css
.c1{ color: red; width: 100%; height: 300px; border: solid 1px red; }
app.js
import './app.css' import React from 'react'; import ReactDOM from 'react-dom'; import './modules/cp/cp.scss' class Component1 extends React.Component{ render(){ return ( <p className="c1"></p> ) } } ReactDOM.render( <Component1 />, document.getElementById('app') )
Inline style
let c1 = { color: 'red', width: '100%', height: '300px', border: 'solid 1px red' } class Component1 extends React.Component{ render(){ console.log(c1) return ( <p style={c1}></p> ) } }
Believe it or not After reading the case in this article, you have mastered the method. For more exciting information, please pay attention to other related articles on the PHP Chinese website!
Recommended reading:
Detailed explanation of the steps to select li highlighting in react
EasyCanvas drawing library is used in Pixeler project development Practical summary
The above is the detailed content of Detailed explanation of using style binding in React. For more information, please follow other related articles on the PHP Chinese website!

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

What software is crystaldiskmark? -How to use crystaldiskmark?

Detailed explanation of obtaining administrator rights in Win11

How to download foobar2000? -How to use foobar2000

Detailed explanation of division operation in Oracle SQL

Teach you how to use the new advanced features of iOS 17.4 'Stolen Device Protection'

BTCC tutorial: How to bind and use MetaMask wallet on BTCC exchange?
