码迷,mamicode.com
首页 > Web开发 > 详细

react加css的3种方法

时间:2018-07-31 19:21:17      阅读:411      评论:0      收藏:0      [点我收藏+]

标签:this   let   引入   back   声明   round   page   reac   end   

1. 行内样式
<div
  style={{
    width:‘200px‘,
    height:‘80px‘,
    backgroundColor:‘yellow‘,
    fontSize:‘24px‘,
    textAlign:‘center‘
  }}
>This is Page1!</div>


2. 声明样式
render(){
  let mystyle={
    width:‘200px‘,
    height:‘80px‘,
    backgroundColor:‘yellow‘,
    fontSize:‘24px‘,
    textAlign:‘center‘
  }
  return(<div>
    <h2 style={mystyle}>This is Page1!</h2>
  </div>);
}


3. 引入样式
require(‘./mystyle.css‘);

react加css的3种方法

标签:this   let   引入   back   声明   round   page   reac   end   

原文地址:https://www.cnblogs.com/zaazoo/p/9397252.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!