Share
Sign In
📄

react에서 반응형 디자인

공식문서에서 나온 Context를 사용하는 반응형 디자인
import { useMediaQuery } from 'react-responsive' const Desktop = ({ children }) => { const isDesktop = useMediaQuery({ minWidth: 992 }) return isDesktop ? children : null } const Tablet = ({ children }) => { const isTablet = useMediaQuery({ minWidth: 768, maxWidth: 991 }) return isTablet ? children : null } const Mobile = ({ children }) => { const isMobile = useMediaQuery({ maxWidth: 767 }) return isMobile ? children : null } const Default = ({ children }) => { const isNotMobile = useMediaQuery({ minWidth: 768 }) return isNotMobile ? children : null } const Example = () => ( <div> <Desktop>Desktop or laptop</Desktop> <Tablet>Tablet</Tablet> <Mobile>Mobile</Mobile> <Default>Not mobile (desktop or laptop or tablet)</Default> </div> ) export default Example
뷰포트를 받아 스케일을 변경하는 방법
뷰포트를 가져옴 : window.innerWidth
import React from 'react' import styled from 'styled-components'; //components import Header from './modules/header/index' import CurrentEatingHabbits from './modules/eating-habits-current' import EatingHabbitsComment from './modules/eating-habits-comment' import MonthlyMenuRanking from './modules/monthly-menu-ranking' import EnvirommentWeProtect from './modules/environment-we-protect' import Footer from'./modules/footer' export default function Report(){ //뷰포트를 가져옴 window.innerWidth let width = window.innerWidth/327 > 2? 1:window.innerWidth/327; console.log(width) return ( <Wrap width={width}> <Header/> <CurrentEatingHabbits/> <EatingHabbitsComment/> <MonthlyMenuRanking/> <EnvirommentWeProtect/> <Footer/> </Wrap> ); } const Wrap = styled.div` position: relative; width: 320px; margin:0 auto; height: auto; background: #FFFFFF; //뷰포트에 맞게 크기를 바꿈 transform:scale(${props =>props.width}); overflow-x:hidden; transform-origin: top; `
CSS에서 미디어쿼리를 이용하는 방법
`/* pc */ @media all and (min-width: 1025px) { .wrap{width:1200px;} } /* tablet */ @media all and (min-width: 768px) and (max-width: 1024px) { .wrap{width:712px;} } /* phone */ @media all and (max-width: 767px) { .wrap{width:320px;} } /* index */
React 홈으로 돌아가기
React.js
메인으로 돌아가기
공식문서에서 나온 Context를 사용하는 반응형 디자인
import { useMediaQuery } from 'react-responsive' const Desktop = ({ children }) => { const isDesktop = useMediaQuery({ minWidth: 992 }) return isDesktop ? children : null } const Tablet = ({ children }) => { const isTablet = useMediaQuery({ minWidth: 768, maxWidth: 991 }) return isTablet ? children : null } const Mobile = ({ children }) => { const isMobile = useMediaQuery({ maxWidth: 767 }) return isMobile ? children : null } const Default = ({ children }) => { const isNotMobile = useMediaQuery({ minWidth: 768 }) return isNotMobile ? children : null } const Example = () => ( <div> <Desktop>Desktop or laptop</Desktop> <Tablet>Tablet</Tablet> <Mobile>Mobile</Mobile> <Default>Not mobile (desktop or laptop or tablet)</Default> </div> ) export default Example
뷰포트를 받아 스케일을 변경하는 방법
뷰포트를 가져옴 : window.innerWidth
import React from 'react' import styled from 'styled-components'; //components import Header from './modules/header/index' import CurrentEatingHabbits from './modules/eating-habits-current' import EatingHabbitsComment from './modules/eating-habits-comment' import MonthlyMenuRanking from './modules/monthly-menu-ranking' import EnvirommentWeProtect from './modules/environment-we-protect' import Footer from'./modules/footer' export default function Report(){ //뷰포트를 가져옴 window.innerWidth let width = window.innerWidth/327 > 2? 1:window.innerWidth/327; console.log(width) return ( <Wrap width={width}> <Header/> <CurrentEatingHabbits/> <EatingHabbitsComment/> <MonthlyMenuRanking/> <EnvirommentWeProtect/> <Footer/> </Wrap> ); } const Wrap = styled.div` position: relative; width: 320px; margin:0 auto; height: auto; background: #FFFFFF; //뷰포트에 맞게 크기를 바꿈 transform:scale(${props =>props.width}); overflow-x:hidden; transform-origin: top; `
CSS에서 미디어쿼리를 이용하는 방법
`/* pc */ @media all and (min-width: 1025px) { .wrap{width:1200px;} } /* tablet */ @media all and (min-width: 768px) and (max-width: 1024px) { .wrap{width:712px;} } /* phone */ @media all and (max-width: 767px) { .wrap{width:320px;} } /* index */
React 홈으로 돌아가기
React.js
메인으로 돌아가기
공식문서에서 나온 Context를 사용하는 반응형 디자인
import { useMediaQuery } from 'react-responsive' const Desktop = ({ children }) => { const isDesktop = useMediaQuery({ minWidth: 992 }) return isDesktop ? children : null } const Tablet = ({ children }) => { const isTablet = useMediaQuery({ minWidth: 768, maxWidth: 991 }) return isTablet ? children : null } const Mobile = ({ children }) => { const isMobile = useMediaQuery({ maxWidth: 767 }) return isMobile ? children : null } const Default = ({ children }) => { const isNotMobile = useMediaQuery({ minWidth: 768 }) return isNotMobile ? children : null } const Example = () => ( <div> <Desktop>Desktop or laptop</Desktop> <Tablet>Tablet</Tablet> <Mobile>Mobile</Mobile> <Default>Not mobile (desktop or laptop or tablet)</Default> </div> ) export default Example
뷰포트를 받아 스케일을 변경하는 방법
뷰포트를 가져옴 : window.innerWidth
import React from 'react' import styled from 'styled-components'; //components import Header from './modules/header/index' import CurrentEatingHabbits from './modules/eating-habits-current' import EatingHabbitsComment from './modules/eating-habits-comment' import MonthlyMenuRanking from './modules/monthly-menu-ranking' import EnvirommentWeProtect from './modules/environment-we-protect' import Footer from'./modules/footer' export default function Report(){ //뷰포트를 가져옴 window.innerWidth let width = window.innerWidth/327 > 2? 1:window.innerWidth/327; console.log(width) return ( <Wrap width={width}> <Header/> <CurrentEatingHabbits/> <EatingHabbitsComment/> <MonthlyMenuRanking/> <EnvirommentWeProtect/> <Footer/> </Wrap> ); } const Wrap = styled.div` position: relative; width: 320px; margin:0 auto; height: auto; background: #FFFFFF; //뷰포트에 맞게 크기를 바꿈 transform:scale(${props =>props.width}); overflow-x:hidden; transform-origin: top; `
CSS에서 미디어쿼리를 이용하는 방법
`/* pc */ @media all and (min-width: 1025px) { .wrap{width:1200px;} } /* tablet */ @media all and (min-width: 768px) and (max-width: 1024px) { .wrap{width:712px;} } /* phone */ @media all and (max-width: 767px) { .wrap{width:320px;} } /* index */
React 홈으로 돌아가기
React.js
메인으로 돌아가기
공식문서에서 나온 Context를 사용하는 반응형 디자인
import { useMediaQuery } from 'react-responsive' const Desktop = ({ children }) => { const isDesktop = useMediaQuery({ minWidth: 992 }) return isDesktop ? children : null } const Tablet = ({ children }) => { const isTablet = useMediaQuery({ minWidth: 768, maxWidth: 991 }) return isTablet ? children : null } const Mobile = ({ children }) => { const isMobile = useMediaQuery({ maxWidth: 767 }) return isMobile ? children : null } const Default = ({ children }) => { const isNotMobile = useMediaQuery({ minWidth: 768 }) return isNotMobile ? children : null } const Example = () => ( <div> <Desktop>Desktop or laptop</Desktop> <Tablet>Tablet</Tablet> <Mobile>Mobile</Mobile> <Default>Not mobile (desktop or laptop or tablet)</Default> </div> ) export default Example
뷰포트를 받아 스케일을 변경하는 방법
뷰포트를 가져옴 : window.innerWidth
import React from 'react' import styled from 'styled-components'; //components import Header from './modules/header/index' import CurrentEatingHabbits from './modules/eating-habits-current' import EatingHabbitsComment from './modules/eating-habits-comment' import MonthlyMenuRanking from './modules/monthly-menu-ranking' import EnvirommentWeProtect from './modules/environment-we-protect' import Footer from'./modules/footer' export default function Report(){ //뷰포트를 가져옴 window.innerWidth let width = window.innerWidth/327 > 2? 1:window.innerWidth/327; console.log(width) return ( <Wrap width={width}> <Header/> <CurrentEatingHabbits/> <EatingHabbitsComment/> <MonthlyMenuRanking/> <EnvirommentWeProtect/> <Footer/> </Wrap> ); } const Wrap = styled.div` position: relative; width: 320px; margin:0 auto; height: auto; background: #FFFFFF; //뷰포트에 맞게 크기를 바꿈 transform:scale(${props =>props.width}); overflow-x:hidden; transform-origin: top; `
CSS에서 미디어쿼리를 이용하는 방법
`/* pc */ @media all and (min-width: 1025px) { .wrap{width:1200px;} } /* tablet */ @media all and (min-width: 768px) and (max-width: 1024px) { .wrap{width:712px;} } /* phone */ @media all and (max-width: 767px) { .wrap{width:320px;} } /* index */
React 홈으로 돌아가기
React.js
메인으로 돌아가기
공식문서에서 나온 Context를 사용하는 반응형 디자인
import { useMediaQuery } from 'react-responsive' const Desktop = ({ children }) => { const isDesktop = useMediaQuery({ minWidth: 992 }) return isDesktop ? children : null } const Tablet = ({ children }) => { const isTablet = useMediaQuery({ minWidth: 768, maxWidth: 991 }) return isTablet ? children : null } const Mobile = ({ children }) => { const isMobile = useMediaQuery({ maxWidth: 767 }) return isMobile ? children : null } const Default = ({ children }) => { const isNotMobile = useMediaQuery({ minWidth: 768 }) return isNotMobile ? children : null } const Example = () => ( <div> <Desktop>Desktop or laptop</Desktop> <Tablet>Tablet</Tablet> <Mobile>Mobile</Mobile> <Default>Not mobile (desktop or laptop or tablet)</Default> </div> ) export default Example
뷰포트를 받아 스케일을 변경하는 방법
뷰포트를 가져옴 : window.innerWidth
import React from 'react' import styled from 'styled-components'; //components import Header from './modules/header/index' import CurrentEatingHabbits from './modules/eating-habits-current' import EatingHabbitsComment from './modules/eating-habits-comment' import MonthlyMenuRanking from './modules/monthly-menu-ranking' import EnvirommentWeProtect from './modules/environment-we-protect' import Footer from'./modules/footer' export default function Report(){ //뷰포트를 가져옴 window.innerWidth let width = window.innerWidth/327 > 2? 1:window.innerWidth/327; console.log(width) return ( <Wrap width={width}> <Header/> <CurrentEatingHabbits/> <EatingHabbitsComment/> <MonthlyMenuRanking/> <EnvirommentWeProtect/> <Footer/> </Wrap> ); } const Wrap = styled.div` position: relative; width: 320px; margin:0 auto; height: auto; background: #FFFFFF; //뷰포트에 맞게 크기를 바꿈 transform:scale(${props =>props.width}); overflow-x:hidden; transform-origin: top; `
CSS에서 미디어쿼리를 이용하는 방법
`/* pc */ @media all and (min-width: 1025px) { .wrap{width:1200px;} } /* tablet */ @media all and (min-width: 768px) and (max-width: 1024px) { .wrap{width:712px;} } /* phone */ @media all and (max-width: 767px) { .wrap{width:320px;} } /* index */
React 홈으로 돌아가기
React.js
메인으로 돌아가기
공식문서에서 나온 Context를 사용하는 반응형 디자인
import { useMediaQuery } from 'react-responsive' const Desktop = ({ children }) => { const isDesktop = useMediaQuery({ minWidth: 992 }) return isDesktop ? children : null } const Tablet = ({ children }) => { const isTablet = useMediaQuery({ minWidth: 768, maxWidth: 991 }) return isTablet ? children : null } const Mobile = ({ children }) => { const isMobile = useMediaQuery({ maxWidth: 767 }) return isMobile ? children : null } const Default = ({ children }) => { const isNotMobile = useMediaQuery({ minWidth: 768 }) return isNotMobile ? children : null } const Example = () => ( <div> <Desktop>Desktop or laptop</Desktop> <Tablet>Tablet</Tablet> <Mobile>Mobile</Mobile> <Default>Not mobile (desktop or laptop or tablet)</Default> </div> ) export default Example
뷰포트를 받아 스케일을 변경하는 방법
뷰포트를 가져옴 : window.innerWidth
import React from 'react' import styled from 'styled-components'; //components import Header from './modules/header/index' import CurrentEatingHabbits from './modules/eating-habits-current' import EatingHabbitsComment from './modules/eating-habits-comment' import MonthlyMenuRanking from './modules/monthly-menu-ranking' import EnvirommentWeProtect from './modules/environment-we-protect' import Footer from'./modules/footer' export default function Report(){ //뷰포트를 가져옴 window.innerWidth let width = window.innerWidth/327 > 2? 1:window.innerWidth/327; console.log(width) return ( <Wrap width={width}> <Header/> <CurrentEatingHabbits/> <EatingHabbitsComment/> <MonthlyMenuRanking/> <EnvirommentWeProtect/> <Footer/> </Wrap> ); } const Wrap = styled.div` position: relative; width: 320px; margin:0 auto; height: auto; background: #FFFFFF; //뷰포트에 맞게 크기를 바꿈 transform:scale(${props =>props.width}); overflow-x:hidden; transform-origin: top; `
CSS에서 미디어쿼리를 이용하는 방법
`/* pc */ @media all and (min-width: 1025px) { .wrap{width:1200px;} } /* tablet */ @media all and (min-width: 768px) and (max-width: 1024px) { .wrap{width:712px;} } /* phone */ @media all and (max-width: 767px) { .wrap{width:320px;} } /* index */
React 홈으로 돌아가기
React.js
메인으로 돌아가기
공식문서에서 나온 Context를 사용하는 반응형 디자인
import { useMediaQuery } from 'react-responsive' const Desktop = ({ children }) => { const isDesktop = useMediaQuery({ minWidth: 992 }) return isDesktop ? children : null } const Tablet = ({ children }) => { const isTablet = useMediaQuery({ minWidth: 768, maxWidth: 991 }) return isTablet ? children : null } const Mobile = ({ children }) => { const isMobile = useMediaQuery({ maxWidth: 767 }) return isMobile ? children : null } const Default = ({ children }) => { const isNotMobile = useMediaQuery({ minWidth: 768 }) return isNotMobile ? children : null } const Example = () => ( <div> <Desktop>Desktop or laptop</Desktop> <Tablet>Tablet</Tablet> <Mobile>Mobile</Mobile> <Default>Not mobile (desktop or laptop or tablet)</Default> </div> ) export default Example
뷰포트를 받아 스케일을 변경하는 방법
뷰포트를 가져옴 : window.innerWidth
import React from 'react' import styled from 'styled-components'; //components import Header from './modules/header/index' import CurrentEatingHabbits from './modules/eating-habits-current' import EatingHabbitsComment from './modules/eating-habits-comment' import MonthlyMenuRanking from './modules/monthly-menu-ranking' import EnvirommentWeProtect from './modules/environment-we-protect' import Footer from'./modules/footer' export default function Report(){ //뷰포트를 가져옴 window.innerWidth let width = window.innerWidth/327 > 2? 1:window.innerWidth/327; console.log(width) return ( <Wrap width={width}> <Header/> <CurrentEatingHabbits/> <EatingHabbitsComment/> <MonthlyMenuRanking/> <EnvirommentWeProtect/> <Footer/> </Wrap> ); } const Wrap = styled.div` position: relative; width: 320px; margin:0 auto; height: auto; background: #FFFFFF; //뷰포트에 맞게 크기를 바꿈 transform:scale(${props =>props.width}); overflow-x:hidden; transform-origin: top; `
CSS에서 미디어쿼리를 이용하는 방법
`/* pc */ @media all and (min-width: 1025px) { .wrap{width:1200px;} } /* tablet */ @media all and (min-width: 768px) and (max-width: 1024px) { .wrap{width:712px;} } /* phone */ @media all and (max-width: 767px) { .wrap{width:320px;} } /* index */
React 홈으로 돌아가기
React.js
메인으로 돌아가기
공식문서에서 나온 Context를 사용하는 반응형 디자인
import { useMediaQuery } from 'react-responsive' const Desktop = ({ children }) => { const isDesktop = useMediaQuery({ minWidth: 992 }) return isDesktop ? children : null } const Tablet = ({ children }) => { const isTablet = useMediaQuery({ minWidth: 768, maxWidth: 991 }) return isTablet ? children : null } const Mobile = ({ children }) => { const isMobile = useMediaQuery({ maxWidth: 767 }) return isMobile ? children : null } const Default = ({ children }) => { const isNotMobile = useMediaQuery({ minWidth: 768 }) return isNotMobile ? children : null } const Example = () => ( <div> <Desktop>Desktop or laptop</Desktop> <Tablet>Tablet</Tablet> <Mobile>Mobile</Mobile> <Default>Not mobile (desktop or laptop or tablet)</Default> </div> ) export default Example
뷰포트를 받아 스케일을 변경하는 방법
뷰포트를 가져옴 : window.innerWidth
import React from 'react' import styled from 'styled-components'; //components import Header from './modules/header/index' import CurrentEatingHabbits from './modules/eating-habits-current' import EatingHabbitsComment from './modules/eating-habits-comment' import MonthlyMenuRanking from './modules/monthly-menu-ranking' import EnvirommentWeProtect from './modules/environment-we-protect' import Footer from'./modules/footer' export default function Report(){ //뷰포트를 가져옴 window.innerWidth let width = window.innerWidth/327 > 2? 1:window.innerWidth/327; console.log(width) return ( <Wrap width={width}> <Header/> <CurrentEatingHabbits/> <EatingHabbitsComment/> <MonthlyMenuRanking/> <EnvirommentWeProtect/> <Footer/> </Wrap> ); } const Wrap = styled.div` position: relative; width: 320px; margin:0 auto; height: auto; background: #FFFFFF; //뷰포트에 맞게 크기를 바꿈 transform:scale(${props =>props.width}); overflow-x:hidden; transform-origin: top; `
CSS에서 미디어쿼리를 이용하는 방법
`/* pc */ @media all and (min-width: 1025px) { .wrap{width:1200px;} } /* tablet */ @media all and (min-width: 768px) and (max-width: 1024px) { .wrap{width:712px;} } /* phone */ @media all and (max-width: 767px) { .wrap{width:320px;} } /* index */
React 홈으로 돌아가기
React.js
메인으로 돌아가기
공식문서에서 나온 Context를 사용하는 반응형 디자인
import { useMediaQuery } from 'react-responsive' const Desktop = ({ children }) => { const isDesktop = useMediaQuery({ minWidth: 992 }) return isDesktop ? children : null } const Tablet = ({ children }) => { const isTablet = useMediaQuery({ minWidth: 768, maxWidth: 991 }) return isTablet ? children : null } const Mobile = ({ children }) => { const isMobile = useMediaQuery({ maxWidth: 767 }) return isMobile ? children : null } const Default = ({ children }) => { const isNotMobile = useMediaQuery({ minWidth: 768 }) return isNotMobile ? children : null } const Example = () => ( <div> <Desktop>Desktop or laptop</Desktop> <Tablet>Tablet</Tablet> <Mobile>Mobile</Mobile> <Default>Not mobile (desktop or laptop or tablet)</Default> </div> ) export default Example
뷰포트를 받아 스케일을 변경하는 방법
뷰포트를 가져옴 : window.innerWidth
import React from 'react' import styled from 'styled-components'; //components import Header from './modules/header/index' import CurrentEatingHabbits from './modules/eating-habits-current' import EatingHabbitsComment from './modules/eating-habits-comment' import MonthlyMenuRanking from './modules/monthly-menu-ranking' import EnvirommentWeProtect from './modules/environment-we-protect' import Footer from'./modules/footer' export default function Report(){ //뷰포트를 가져옴 window.innerWidth let width = window.innerWidth/327 > 2? 1:window.innerWidth/327; console.log(width) return ( <Wrap width={width}> <Header/> <CurrentEatingHabbits/> <EatingHabbitsComment/> <MonthlyMenuRanking/> <EnvirommentWeProtect/> <Footer/> </Wrap> ); } const Wrap = styled.div` position: relative; width: 320px; margin:0 auto; height: auto; background: #FFFFFF; //뷰포트에 맞게 크기를 바꿈 transform:scale(${props =>props.width}); overflow-x:hidden; transform-origin: top; `
CSS에서 미디어쿼리를 이용하는 방법
`/* pc */ @media all and (min-width: 1025px) { .wrap{width:1200px;} } /* tablet */ @media all and (min-width: 768px) and (max-width: 1024px) { .wrap{width:712px;} } /* phone */ @media all and (max-width: 767px) { .wrap{width:320px;} } /* index */
React 홈으로 돌아가기
React.js
메인으로 돌아가기
공식문서에서 나온 Context를 사용하는 반응형 디자인
import { useMediaQuery } from 'react-responsive' const Desktop = ({ children }) => { const isDesktop = useMediaQuery({ minWidth: 992 }) return isDesktop ? children : null } const Tablet = ({ children }) => { const isTablet = useMediaQuery({ minWidth: 768, maxWidth: 991 }) return isTablet ? children : null } const Mobile = ({ children }) => { const isMobile = useMediaQuery({ maxWidth: 767 }) return isMobile ? children : null } const Default = ({ children }) => { const isNotMobile = useMediaQuery({ minWidth: 768 }) return isNotMobile ? children : null } const Example = () => ( <div> <Desktop>Desktop or laptop</Desktop> <Tablet>Tablet</Tablet> <Mobile>Mobile</Mobile> <Default>Not mobile (desktop or laptop or tablet)</Default> </div> ) export default Example
뷰포트를 받아 스케일을 변경하는 방법
뷰포트를 가져옴 : window.innerWidth
import React from 'react' import styled from 'styled-components'; //components import Header from './modules/header/index' import CurrentEatingHabbits from './modules/eating-habits-current' import EatingHabbitsComment from './modules/eating-habits-comment' import MonthlyMenuRanking from './modules/monthly-menu-ranking' import EnvirommentWeProtect from './modules/environment-we-protect' import Footer from'./modules/footer' export default function Report(){ //뷰포트를 가져옴 window.innerWidth let width = window.innerWidth/327 > 2? 1:window.innerWidth/327; console.log(width) return ( <Wrap width={width}> <Header/> <CurrentEatingHabbits/> <EatingHabbitsComment/> <MonthlyMenuRanking/> <EnvirommentWeProtect/> <Footer/> </Wrap> ); } const Wrap = styled.div` position: relative; width: 320px; margin:0 auto; height: auto; background: #FFFFFF; //뷰포트에 맞게 크기를 바꿈 transform:scale(${props =>props.width}); overflow-x:hidden; transform-origin: top; `
CSS에서 미디어쿼리를 이용하는 방법
`/* pc */ @media all and (min-width: 1025px) { .wrap{width:1200px;} } /* tablet */ @media all and (min-width: 768px) and (max-width: 1024px) { .wrap{width:712px;} } /* phone */ @media all and (max-width: 767px) { .wrap{width:320px;} } /* index */
React 홈으로 돌아가기
React.js
메인으로 돌아가기
공식문서에서 나온 Context를 사용하는 반응형 디자인
import { useMediaQuery } from 'react-responsive' const Desktop = ({ children }) => { const isDesktop = useMediaQuery({ minWidth: 992 }) return isDesktop ? children : null } const Tablet = ({ children }) => { const isTablet = useMediaQuery({ minWidth: 768, maxWidth: 991 }) return isTablet ? children : null } const Mobile = ({ children }) => { const isMobile = useMediaQuery({ maxWidth: 767 }) return isMobile ? children : null } const Default = ({ children }) => { const isNotMobile = useMediaQuery({ minWidth: 768 }) return isNotMobile ? children : null } const Example = () => ( <div> <Desktop>Desktop or laptop</Desktop> <Tablet>Tablet</Tablet> <Mobile>Mobile</Mobile> <Default>Not mobile (desktop or laptop or tablet)</Default> </div> ) export default Example
뷰포트를 받아 스케일을 변경하는 방법
뷰포트를 가져옴 : window.innerWidth
import React from 'react' import styled from 'styled-components'; //components import Header from './modules/header/index' import CurrentEatingHabbits from './modules/eating-habits-current' import EatingHabbitsComment from './modules/eating-habits-comment' import MonthlyMenuRanking from './modules/monthly-menu-ranking' import EnvirommentWeProtect from './modules/environment-we-protect' import Footer from'./modules/footer' export default function Report(){ //뷰포트를 가져옴 window.innerWidth let width = window.innerWidth/327 > 2? 1:window.innerWidth/327; console.log(width) return ( <Wrap width={width}> <Header/> <CurrentEatingHabbits/> <EatingHabbitsComment/> <MonthlyMenuRanking/> <EnvirommentWeProtect/> <Footer/> </Wrap> ); } const Wrap = styled.div` position: relative; width: 320px; margin:0 auto; height: auto; background: #FFFFFF; //뷰포트에 맞게 크기를 바꿈 transform:scale(${props =>props.width}); overflow-x:hidden; transform-origin: top; `
CSS에서 미디어쿼리를 이용하는 방법
`/* pc */ @media all and (min-width: 1025px) { .wrap{width:1200px;} } /* tablet */ @media all and (min-width: 768px) and (max-width: 1024px) { .wrap{width:712px;} } /* phone */ @media all and (max-width: 767px) { .wrap{width:320px;} } /* index */
React 홈으로 돌아가기
React.js
메인으로 돌아가기
공식문서에서 나온 Context를 사용하는 반응형 디자인
import { useMediaQuery } from 'react-responsive' const Desktop = ({ children }) => { const isDesktop = useMediaQuery({ minWidth: 992 }) return isDesktop ? children : null } const Tablet = ({ children }) => { const isTablet = useMediaQuery({ minWidth: 768, maxWidth: 991 }) return isTablet ? children : null } const Mobile = ({ children }) => { const isMobile = useMediaQuery({ maxWidth: 767 }) return isMobile ? children : null } const Default = ({ children }) => { const isNotMobile = useMediaQuery({ minWidth: 768 }) return isNotMobile ? children : null } const Example = () => ( <div> <Desktop>Desktop or laptop</Desktop> <Tablet>Tablet</Tablet> <Mobile>Mobile</Mobile> <Default>Not mobile (desktop or laptop or tablet)</Default> </div> ) export default Example
뷰포트를 받아 스케일을 변경하는 방법
뷰포트를 가져옴 : window.innerWidth
import React from 'react' import styled from 'styled-components'; //components import Header from './modules/header/index' import CurrentEatingHabbits from './modules/eating-habits-current' import EatingHabbitsComment from './modules/eating-habits-comment' import MonthlyMenuRanking from './modules/monthly-menu-ranking' import EnvirommentWeProtect from './modules/environment-we-protect' import Footer from'./modules/footer' export default function Report(){ //뷰포트를 가져옴 window.innerWidth let width = window.innerWidth/327 > 2? 1:window.innerWidth/327; console.log(width) return ( <Wrap width={width}> <Header/> <CurrentEatingHabbits/> <EatingHabbitsComment/> <MonthlyMenuRanking/> <EnvirommentWeProtect/> <Footer/> </Wrap> ); } const Wrap = styled.div` position: relative; width: 320px; margin:0 auto; height: auto; background: #FFFFFF; //뷰포트에 맞게 크기를 바꿈 transform:scale(${props =>props.width}); overflow-x:hidden; transform-origin: top; `
CSS에서 미디어쿼리를 이용하는 방법
`/* pc */ @media all and (min-width: 1025px) { .wrap{width:1200px;} } /* tablet */ @media all and (min-width: 768px) and (max-width: 1024px) { .wrap{width:712px;} } /* phone */ @media all and (max-width: 767px) { .wrap{width:320px;} } /* index */
React 홈으로 돌아가기
React.js
메인으로 돌아가기