๐ ๋ฐ์ํ ์น์ด๋?
๋ฐ์ํ ์น ๋์์ธ์ด๋ ์ฌ๋ฌ ์ฅ์น์ ๋ค์ํ ํน์ฑ์ ๋์ํ๋ ํ๋์ ์น ๋ฌธ์ ๋๋ ์ฌ์ดํธ๋ก์จ,
๋ธ๋ผ์ฐ์ ์ ํฌ๊ธฐ(์คํฌ๋ฆฐ์ ํฌ๊ธฐ, ๋๋ฐ์ด์ค์ ์ข ๋ฅ)์ ์ค์๊ฐ์ผ๋ก ๋ฐ์ํ์ฌ ํฌ๊ธฐ์ ๋ฐ๋ผ ๋ ์ด์์์ด ๋ณํ๋ ์น ์ฌ์ดํธ๋ฅผ ์๋ฏธํ๋ค.
- ์ฆ, ํ๋์ ์์ค ์ฝ๋๋ก ๋ชจ๋ ์คํฌ๋ฆฐ์ ์ต์ ํ๋ ์น ์ฌ์ดํธ๋ฅผ ๊ตฌ์ถํ ์ ์๋ ๋ฐฉ๋ฒ๋ก , ๋๋ฐ์ด์ค ์ข ๋ฅ์ ๋ฐ๋ผ ์นํ์ด์ง์ ํฌ๊ธฐ๊ฐ ์๋์ ์ผ๋ก ์ฌ์กฐ์ ๋๋ ๊ฒ์ด๋ค.
- ๋ฐ์ํ ์น์ ํ๋์ URL์ ๊ธฐ๋ฐ์ผ๋ก ํ๋ฉด์ด ๋ฐ๋๋ค. ๋ฐ์ํ ์น ๋์์ธ์ ์ ์ฐํ ๋ ์ด์์์ ๋์ํ์ฌ ํญ์ ์ต์ ์ ํ๋ฉด์ ์ ๊ณตํจ์ผ๋ก์จ ๋ค์ํ ์คํฌ๋ฆฐ ์ฌ์ด์ฆ๋ฅผ ์ง๋ ๋๋ฐ์ด์ค์ ์ ์ํ ์ ์๋ค.
- ํน์ ์ฅ์น์ ์ฐ๊ฒฐ์ด ๋๋ ๋ณ๋์ URL์ ๋ชจ๋ฐ์ผ์ ๊ฒฝ์ฐ ๋๊ฐ m.domainname.com ๊ฐ์ ์์ผ๋ก, ๋๋ฉ์ธ ์์ ๋ชจ๋ฐ์ผ์ ์๋ฏธํ๋ “m”์ ๋ถ์์ผ๋ก์จ ๊ตฌ๋ถํฉ๋๋ค. ํน์ ์ฅ์น์ ์ฐ๊ฒฐ์ด ๋๋ ๋ณ๋์ URL๊ณผ ํ๋ฉด์ด ๊ตฌ๋น๋ ์น ์ฌ์ดํธ์ ๊ฒฝ์ฐ, ๋ฐ์คํฌํ ๋ฒ์ ์ ์น ์ฌ์ดํธ๋ฅผ ๋์ด ๋ธ๋ผ์ฐ์ ๋ฅผ ์ค์์ ๋ ๋ฐ์ํ์ง ์๋๋ค.
๐ ๋ฏธ๋์ด์ฟผ๋ฆฌ
๋ฏธ๋์ด ์ฟผ๋ฆฌ๋ ๋ฐ์ํ ์น ๋์์ธ์ ํต์ฌ ๋ถ๋ถ๋ค.
๋ทฐํฌํธ(๋ธ๋ผ์ฐ์ ์ฐฝ)์ ํฌ๊ธฐ์ ๋ฐ๋ผ ์๋ก ๋ค๋ฅธ ์กฐํ์ ์์ฑํ ์ ์๊ธฐ ๋๋ฌธ์ด๋ค.
๋ฏธ๋์ด ์ฟผ๋ฆฌ ์ ์ฉ๋ฒ
1. CSS ํ์ผ์ HTML ํ์ผ์ ์ ์ฉํ๋ ๊ฒ์ฒ๋ผ <head>ํ๊ทธ ์์ <link>ํ๊ทธ๋ฅผ ์์น ์ํจ๋ค.
๋ค๋ฅธ css ํ์ผ์ ์ ์ฉํ ๋์ ๋ค๋ฅธ ์ ์ ๋ฏธ๋์ด ์์ฑ์ ์ฌ์ฉํ์ฌ ์กฐ๊ฑด์ ์ง์ ํ๋ค๋ ์ ์ด๋ค.
๋ฏธ๋์ด ์์ฑ ๋ด ํด๋น ์กฐ๊ฑด์ ๋ง์กฑํ ๋์๋ง ํด๋น css ํ์ผ์ ๋ถ๋ฌ์ค๊ฒ ๋๋ค.
<link href="cssํ์ผ์ด๋ฆ.css" media="screen and (min-width: 400px) and (max-width: 1000px)" rel="stylesheet">
2. HTML ํ์ผ ๋ด <head>ํ๊ทธ ์์์ <style>ํ๊ทธ๋ฅผ ์ด์ด ๋ฏธ๋์ด ์ฟผ๋ฆฌ๋ฅผ ์์ฑ.
์ด ๋ฐฉ๋ฒ๋ ๋ฏธ๋์ด ์์ฑ ๋ด ํด๋น ์กฐ๊ฑด์ ๋ง์กฑํ ๋์๋ง ํด๋น ์คํ์ผ์ ์ ์ฉํ๊ฒ ๋๋ค.
<style type="text/css" media="screen and (min-width: 400px) and (max-width: 1000px)">
/* ์ฌ๊ธฐ css๋ฅผ ์์ฑํฉ๋๋ค. */
</style>
3. CSS ํ์ผ ํน์ ํ๊ทธ ์์์ ์ง์ ๋ฏธ๋์ด ์ฟผ๋ฆฌ ์์ฑ
@media ๋ฏธ๋์ด ํ์
(์กฐ๊ฑด(๋๋น ๋ฐ ๋์ด)) {
(CSS ์
๋ ฅํ๋ ๋ถ๋ถ)
}
--์์
@media screen (max-width: 400px) {
body {
color: red;
}
}
- ๋ฏธ๋์ด ํ์ : ์ฝ๋๊ฐ ์ด๋ค ๋ฏธ๋์ด๋ฅผ ์ํ ๊ฒ์ธ์ง ๋ธ๋ผ์ฐ์ ์ ์๋ ค์ค๋ค.
- ์กฐ๊ฑด(๋๋น ๋ฐ ๋์ด) : ์ง์ ํ ์ฐฝ์ ๋๋น๋ ๋์ด๋ฅผ ๊ธฐ์ค์ผ๋ก ๊ธฐ์ค์ด ๋ง์กฑ๋๋ฉด ์คํ์ผ์ด ์ ์ฉ๋๊ณ , ๋ง์กฑ๋์ง ์์ผ๋ฉด ์ ์ฉ๋์ง ์๋๋ค.
- CSS ์ ๋ ฅํ๋ ๋ถ๋ถ : ์กฐ๊ฑด๋ฌธ์ ํต๊ณผํ๊ณ , ๋ฏธ๋์ด ํ์ ์ด ์ฌ๋ฐ๋ฅธ ๊ฒฝ์ฐ ์คํ์ผ์ด ์ ์ฉ ๋๋ค.
๋ฏธ๋์ด ํ์ (Media Type)
- all : ๋ชจ๋ ๋ฏธ๋์ด ํ์
- print : ํ๋ฆฐํฐ
- screen : ์ปดํจํฐ ํ๋ฉด
- speech : ์คํฌ๋ฆฐ ๋ฆฌ๋
์กฐ๊ฑด(๋๋น ๋ฐ ๋์ด)
width(ํน์ height)๋ ๋ธ๋ผ์ฐ์ ์ ์ฐฝ ํฌ๊ธฐ์ ์ฌ์ฉํ ์ ์๋ค.
@media screen and (width: 600px) {
body {
color : red;
}
}โ
min- ํน์ max- ์ ๋์ฌ๋ฅผ ๋ถ์ด๊ฒ ๋๋ฉด ์ต์๊ฐ์ธ์ง ์ต๋๊ฐ์ธ์ง ํ์ํ ์ ์๋ค.
//๋ทฐํฌํธ๊ฐ 400px ๋ณด๋ค ์ข์ ๊ฒฝ์ฐ ์์ ํ๋์์ผ๋ก ๋ง๋ค๊ธฐ
@media screen and (max-width: 400px) {
body {
color: blue;
}
}
๐ ์์ฑ์
๐ ์ฐธ์กฐ ์ฌ์ดํธ
1. MainArea ์คํ์ผ๋ ์ปดํฌ๋ํธ
1. background-image URL์ ์ด๋ฏธ์ง ์ฃผ์ ๋ณต์ฌํด์ ๋ฃ๊ธฐ. (์ด๋ฏธ์ง ์ฐธ์กฐ : unsplash)
3. ์์ฑ์ ๋ณ๊ฒฝํ ๋ ์ ๋๋ฉ์ด์ ์๋๋ฅผ ์กฐ์ ํ๋ ๋ฐฉ๋ฒ
Render.js
import styled from "styled-components";
import "../App.css";
const BREAK_POINT_TABLET = 768;
const MainArea = styled.div`
background-image: url(https://images.unsplash.com/photo-1610641818989-c2051b5e2cfd?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2670&q=80);
background-repeat: no-repeat;
background-position: center;
display: flex;
justify-content: center;
align-items: center;
max-height: 864px;
height: 100vh;
width: 100%;
transition: 0.5s;
div.text {
p {
transition: 0.5s;
color: white;
font-size: 150px;
}
}
@media only screen and (max-width: ${BREAK_POINT_TABLET}px) {
background-image: url(https://images.unsplash.com/photo-1551918120-9739cb430c6d?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=987&q=80);
transition: 0.5s;
div.text {
p {
transition: 0.5s;
color: white;
font-size: 60px;
}
}
}
`;
const Render = () => {
return (
<>
<MainArea>
<div className="text">
<p>Enjoy Hawaii</p>
</div>
</MainArea>
</>
);
};
export default Render;
2. App.css
1. ๊ตฌ๊ธ ํฐํธ์์ importํ๊ธฐ
+ ๋ฒํผ์ผ๋ก ํฐํธ ์ ํํ ๋ค Use on the web @import ๋ผ๋์ค ๋ฒํผ ํด๋ฆญ. ์คํ์ผ ํ๊ทธ ์์ ์๋ ๊ตฌ๋ฌธ css ํ์ผ ์๋จ์ ์ ๋ ฅํ๋ค.
CSS rules to specify families ์์ font-family: 'Satisfy' ๋ฅผ * ์ ์ฒด ์ ํ์์ ์ ๋ ฅํ๋ค.
App.css
@import url("https://fonts.googleapis.com/css2?family=Concert+One&family=Satisfy&display=swap");
* {
font-family: "Satisfy";
box-sizing: border-box;
padding: 0px;
margin: 0px;
list-style: none;
text-decoration: none;
-ms-overflow-style: none;
scrollbar-width: none;
}
*::-webkit-scrollbar {
display: none;
}
body {
height: 100%;
overflow: scroll;
}
๋ทฐํฌํธ์ ๋ฐ๋ผ ์ด๋ฏธ์ง ์ฌ์ด์ฆ๊ฐ ๋ฐ๋๋ ๊ฒ ๋ง์ผ๋ก๋ ์์ ๊ฐ์๋ ๋ฐ์ํ ์น ํ์ด์ง๊ฐ ๋๋ค.
๋ ํผ๋ฐ์ค ์ฌ์ดํธ์์ ๋ฐฐ๊ฒฝ ํธ๋ ์ง์ ํ๋๊ฒ ๊ฐ๋จํด๋ณด์ฌ ๋์ ํ๋๋ฐ ์์ง ์ ์ฉ๋ฒ์ด ์ด์ํด์ ์๊ทผํ ์๊ฐ์ด ๋ง์ด ๊ฑธ๋ ธ๋ค.
์ฝ๋๋ฅผ ์๋ก ์์ฑํ๋๊ฒ๋ ์ด๋ ต์ง๋ง ์คํ๋ฆฐํธ ์ฝ๋๋ฅผ ๋ฆฌํฉํ ๋งํ๋ฉด์ ์ ์ฌ์ ์์ ๋ฃ๊ณ ํ๊ทธ ์ง์ฐ๋ฉด์ ํ๋ ์คํฌ์ด ๋ ํ์ํ๋ค.
๋ค์ ์๊ฐ์๋ ์กฐ๊ธ ๋ ๋๋ฒจ๋กญํด ์บ๋ฒ์ค ํ๊ทธ๋ฅผ ์ด์ฉํด ์์ฑ๋ ๋์ ๋ฐ์ํ ์น ํ์ด์ง๋ฅผ ๊ตฌํํด๋ด์ผ๊ฒ ๋ค.
'HTML, CSS' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
FrontEnd แแ ตแแ ฎแฏ แแ งแซแแ ฅแธ ์ง๋ฌธ ๋ฆฌ์คํธ (0) | 2022.10.26 |
---|---|
HTML/CSS ์ฌํ ๋ธ๋ผ์ฐ์ (0) | 2022.07.21 |
HTML ํ๊ทธ ๊ตฌ๋ณํ๊ธฐ (0) | 2022.05.05 |
HTML ์๋งจํฑ ํ๊ทธ, ์ค์ํ ํ๊ทธ๋ค ๋ชจ์ (0) | 2022.05.04 |
Visual Studio Code HTML ๋ฌธ์ ์์ฑํ๋ฉด์ ๋ชจ์ ํ์ธํ๊ธฐ ์ข์ ํ์ฅ๋๊ตฌ (0) | 2022.04.29 |