관리 메뉴

me made it !

[React] flex에 대하여 (반응형 레이아웃 만들기) 본문

TIL/React

[React] flex에 대하여 (반응형 레이아웃 만들기)

yeoney 2023. 9. 4. 16:37
반응형
 

 

flexDirection
row
react nativecolumn

 
 

import { StatusBar } from 'expo-status-bar';
import React from "react"
import {View} from 'react-native';

export default function App() {
  return (
    <View style={{ flex : 1 }}>
      <View 
      style={{ flex : 1, backgroundColor:"tomato"}}>
      </View>
      <View 
      style={{ flex : 2, backgroundColor:"teal"}}>
      </View>
      <View 
      style={{ flex : 1, backgroundColor:"orange"}}>
      </View>
    </View>
 
);

}

 

 

import { StatusBar } from 'expo-status-bar';
import React from "react"
import {View} from 'react-native';

export default function App() {
  return (
    <View style={{ flex : 1 , flexDirection:"row"}}>
      <View 
      style={{ flex : 1, backgroundColor:"tomato"}}>
      </View>
      <View 
      style={{ flex : 1, backgroundColor:"teal"}}>
      </View>
      <View 
      style={{ flex : 1, backgroundColor:"orange"}}>
      </View>
    </View>
 
);

}

 

부모의 flex 수치는 자식들의 flex값의 기준이 되는 값이다 
( 즉 값이 변경되어도 자식들의 크기은 변화 이상 무 . ) 
자식들의 flex 수치를 바꾸면 width, height 값을 구체적으로 지정하지 않아도 레이아웃에 맞게 반응형으로 크기가 바뀜!

반응형

'TIL > React' 카테고리의 다른 글

[React] 날씨 앱 만들기  (0) 2023.09.05
[React]  (0) 2023.09.05
[React]  (0) 2023.09.04
[React] Snack을 아시나요..?  (0) 2023.09.03
[React] #2 THE BASICS OF REACT  (0) 2023.09.03