import React , {Component} from 'react';


class App extends Component{
  render(){

    const style = {
      backgroundColor : 'gray',
      border:'1px solid black',
      height:Math.random(Math.random() * 500 ) + 50,
      width:Math.random(Math.random() * 500) + 50,
      WebkitTransition:'all',
      MozTransition:'all',
      msTransition:'all'
    };


    return(
      <div>
        <h1>리액트 테스트</h1>
        <div style={style}></div>
      </div>
    )
  }
}

export default App;

보이는 화면

 

 

Import 방식

App.css

.my-div{
  background-color: aqua;
  font-size: 15px;
}

 

 

App.js

import React , {Component} from 'react';
import './App.css'

class App extends Component{
  render(){

    const style = {
      backgroundColor : 'gray',
      border:'1px solid black',
      height:Math.random(Math.random() * 500 ) + 50,
      width:Math.random(Math.random() * 500) + 50,
      WebkitTransition:'all',
      MozTransition:'all',
      msTransition:'all'
    };


    return(
      <div className="my-div"> 
        <h1>리액트 테스트</h1>
        <div style={style}></div>
      </div>
    )
  }
}

export default App;

className 으로 div 를 설정한이후 App.css 를 import 한이후 사용한다.

 

설정시 보이는 화면

'프로그래밍언어 > React' 카테고리의 다른 글

React Component 불러오기 (props)  (0) 2019.07.20
React 주석  (0) 2019.07.20
React if문  (0) 2019.07.20
React App.js  (0) 2019.07.20
Create-react-app V2 변경 적용사항.  (0) 2019.07.13

+ Recent posts