Responsive Web - boostcampwm-2022/web36-Japari GitHub Wiki
Responsive Web
-
๊ฒ์ ํ๋ซํผ์ด๊ธฐ ๋๋ฌธ์ ์ฌ์ฉ์๋ค์ด ํ๋ฉด์ ๋ณด์์ ๋, ์ ๋ณด๊ฐ ํ ๋์ ๋ค์ด์ฌ ์ ์๋๋ก ์ปดํฌ๋ํธ๋ค์ด ๋ชจ๋ ํ ํ๋ฉด์ ๋ค์ด์ค๊ฒ๋ ๋ง๋ค์ด์ผํ๋ค๊ณ ์๊ฐํ์ต๋๋ค.
-
๊ฐ๋ก 100rem, ์ธ๋ก 62rem์ ๊ธฐ์ค์ผ๋ก ์ปดํฌ๋ํธ๋ค์ด ํ๋ฉด ๋ด์ ๋ชจ๋ ๋ค์ด์ฌ ์ ์๋๋ก html์ font-size๋ฅผ ๋ทฐ ํฌํธ์ ์๋ ํฌ๊ธฐ๋ก ์ค์ ํ์์ต๋๋ค.
* { font-family: "LINESeed KR"; font-size: max(8px, min(1vw, 100vh / 62)); }
ํ๋ฉด ํฌ๊ธฐ์ ๋ฐ๋ผ ๋์ ์ผ๋ก ๋ณ๊ฒฝ๋๋ ์ปดํฌ๋ํธ ํฌ๊ธฐ
-
์ด๋ ๊ฒ ํ์ ๋, ์บ์น๋ง์ธ๋์ canvas ํฌ๊ธฐ ๋ํ ๋ฐ์ํ์ผ๋ก ๋ฐ๊พธ์ด์ฃผ์ด์ผํ์ต๋๋ค.
-
resize ์ด๋ฒคํธ๊ฐ ์ผ์ด๋ ๋, canvas ์ฌ์ด์ฆ๋ฅผ ๋ถ๋ชจ ์์์ ์ฌ์ด์ฆ๋ก ๋ง์ถ์ด canvas์ ํฌ๊ธฐ ๋ํ ์กฐ์ ํ์์ต๋๋ค.
const resizeCanvas = () => { if (!canvasRef.current) return; const canvas = canvasRef.current; if (canvas.parentElement) { canvas.width = canvas.parentElement.clientWidth; canvas.height = canvas.parentElement.clientHeight; } };
-
๊ทผ๋ฐ ์ฌ๊ธฐ์, canvas์ ์ฌ์ด์ฆ๋ฅผ ๋ณ๊ฒฝํ๋ฉด ์บ๋ฒ์ค ์์ ๊ทธ๋ฆผ๋ค์ด ๋ชจ๋ ์ฌ๋ผ์ง ๋ฌธ์ ๊ฐ ์์์ต๋๋ค. ๊ทธ๋์ ์์์ ์บ๋ฒ์ค ํ๋๋ฅผ ์์ฑํ์ฌ ํด๋น ์บ๋ฒ์ค์ ํ์ฌ ๊ทธ๋ฆผ ์ด๋ฏธ์ง๋ฅผ ์ ์ฅํ๊ณ , ๊ธฐ์กด ์บ๋ฒ์ค์ ์ฌ์ด์ฆ ๋ณ๊ฒฝํ ๋ค, ๋ค์ ์ฎ๊ธฐ๋ ์์ผ๋ก ๋ก์ง์ ์์ฑํ์ฌ ํด๊ฒฐํ์์ต๋๋ค.
const resizeCanvas = () => { if (!canvasRef.current) return; const canvas = canvasRef.current; const ctx = getContextObject(); const canvasBack = document.createElement("canvas"); canvasBack.width = canvas.width; canvasBack.height = canvas.height; const ctxBack = canvasBack.getContext("2d"); ctxBack?.drawImage(canvas, 0, 0); if (canvas.parentElement) { canvas.width = canvas.parentElement.clientWidth; canvas.height = canvas.parentElement.clientHeight; ctx.drawImage(canvasBack, 0, 0, canvas.width, canvas.height); } ... };
ํ๋ฉด ํฌ๊ธฐ๊ฐ ๋ณ๊ฒฝ๋์ด๋ ์ ์ง๋๋ ์บ๋ฒ์ค์ ๊ทธ๋ฆผ
-