ํ์ค์ ์กด์ฌํ๋ ์ฐจ์๋ค:
- first-dimension: the world of linear- elements
- second-dimension: the world of plane-elements
- third-dimension: the world of space-elements
์น์ฌ์ดํธ์ ๊ฒฝ์ฐ, 2์ฐจ์๊ณผ 3์ฐจ์์ ๊ฒฐํฉํ์ฌ ๋ง๋ ๊ฒ์ด๋ค.
์น์์์ 3์ฐจ์ ์์๋?: ๊ฐ ์์ ๊ฐ ๋ ์ด์ด๊ฐ ์๋ ํํ
(์์์ ๋ฐฐ์น๊ฐ ๊ณ์ ธ์๋ ๋ชจ์ต)
์น์ ์์๋ฅผ 2์ฐจ์ ํน์ 3์ฐจ์์ผ๋ก ๊ตฌ๋ถํ๋ ค๋ฉด ์ธ ๊ฐ์ง๋ฅผ ๊ณ ๋ คํ ์ ์๋ค.
์น์ ์กด์ฌํ๋ ๊ฐ ์ฐจ์์ ์์ (position ์์ฑ๊ฐ):
2์ฐจ์ ์์
- static: ๋ถ๋ชจ ์์ ๊ฐ ๋ฐ์ํ๋ ๋ง์ง ๋ณํฉ ํ์์ด ๋ฐ์ํ๊ณ , (๋ถ๋ชจ๊ฐ ๋์ด๊ฐ์ ๊ฐ์ง๊ณ ์์ง ์์ ๊ฒฝ์ฐ) ์์์ ๋์ด๊ฐ์ด ๋ถ๋ชจ์ ๋์ด๊ฐ์ ์ํฅ์ ์ค๋ค.
2 || 3์ฐจ์ ์์
- relative: ๋ง์ง ๋ณํฉ ํ์์ด ๋ฐ์ํ๊ณ , top, left, right bottom CSS ์์ฑ ์ฌ์ฉ ๊ฐ๋ฅ
3์ฐจ์ ์์
- absolute: (top~bottm ์์ฑ ์ฌ์ฉ ๊ฐ๋ฅ)
- fixed: (top~bottm ์์ฑ ์ฌ์ฉ ๊ฐ๋ฅ)
<style>
.static_p {
width: 300px;
/* ๋ถ๋ชจ์ ๋์ด๊ฐ์ด ์์ผ๋ฉด ์์์ ๋์ด๊ฐ์ ์ํฅ์ ๋ฐ์. ๊ฐ์ด ์์น*/
/* height: 300px; */
background-color: yellow;
}
/* ์์์์์ ๋ง์ง ๊ฐ์ ์กฐ์ ํ๋ฉด,
๋ถ๋ชจ์์๊ฐ position ๊ฐ์ด ์์ ๊ฒฝ์ฐ ๊ฐ์ด ์ํฅ์ ์ค๋ค.*/
.static_c {
/* ๋ช
์์ ์ผ๋ก ์ค์ ์ ํ์ง ์์๋, ์์์์ position: static
(๋ชจ๋ html ์์๋ค์ default ๊ฐ์ผ๋ก position: static */
/* position: static; */
width: 100px;
height: 100px;
background-color: blue;
/* margin-top: 100px; */
/* top: 100px; 2์ฐจ์ ์์์ด๋ฏ๋ก ์ ์ฉ ์๋จ. */
}
</style>
static: default value, margin ๋ณํฉ ํ์ O, ์์์ ๋์ด๊ฐ์ด ๋ถ๋ชจ์ ๋ ธ๋์ด๊ฐ์ ์ํฅ O
<style>
.fixed_p {
width: 300px;
/* height: 300px;
๋ถ๋ชจ์ height๋ฅผ ์ค์ ํ์ง ์์ ๊ฒฝ์ฐ,
๋ถ๋ชจ ์์ ์ฌ๋ผ์ง ์์์ ์์ฑ๊ฐ์ด ๋ถ๋ชจ์ ์ํฅ์ ์ฃผ์ง ๋ชปํ๋ค.*/
background-color: yellow;
}
.fixed_c {
position: fixed; /*ํ๋ฉด์ด ์์ง์ด๋ฉด ํ๋ฉด๊ณผ ๊ฐ์ด ์์ง์*/
width: 100px;
height: 100px;
background-color: blue;
margin-top: 100px; /* fixed ์ ์ฉ ์,
์์ ์์๋ง ์๋๋ก 100px์ด๋, ๋ถ๋ชจ์๋ ๋ง์ง ๋ณํฉ ํ์ X */
top: 100px;
/*fixed ์ ์ฉ ์, ์ต์ด ์์น์์
๋ธ๋ผ์ฐ์ ์ต์๋จ ๊ธฐ์ค์ผ๋ก ๋ฐ์ผ๋ก 100px ์ด๋:
top~bottom ์์ฑ ์ ์ฉ ๊ฐ๋ฅ*/
}
</style>
fixed: margin ๋ณํฉ ํ์ X, top~bottom ์ ์ฉ๊ฐ๋ฅ, ์์์ ๋์ด๊ฐ์ด ๋ถ๋ชจ ๋์ด๊ฐ์ ์ํฅ X (3์ฐจ์ ์์ ํน์ง)
<style>
.relative_p {
width: 300px;
/* ์์์ ๋์ด๊ฐ๋งํผ ๋ถ๋ชจ์ ๋์ด๊ฐ์ด ๋ณ๊ฒฝ. ๋ถ๋ชจ๊ฐ์ ์ํฅ. */
/* height: 300px; */
background-color: yellow;
}
.relative_c {
position: relative;
width: 100px;
height: 100px;
background-color: blue;
/* ๋ถ๋ชจํ๊ทธ๋ ์์ํ๊ทธ์ ๊ฐ์ด ์์ง์. ๋ง์ง ๋ณํฉ ํ์ O */
margin-top: 100px;
/* ์์์์๊ฐ ์ต์ด ์์น ๊ธฐ์ค์ผ๋ก 100px ๋งํผ ์ด๋. top~bottom ์์ฑ ์ ์ฉ ๊ฐ๋ฅ*/
top: 100px;
}
</style>
relative: margin ๋ณํฉ ํ์ O, top~bottom ์์ฑ ์ ์ฉ ๊ฐ๋ฅ, ์์์ ๋์ด๊ฐ์ด ๋ถ๋ชจ์ ๋์ด๊ฐ์ ์ํฅ
<style>
.absolute_p {
position: relative;
width: 300px;
/* ์์์ ๋์ด๊ฐ์ด ๋ถ๋ชจ์ ๋์ด๊ฐ์ ์ํฅ X*/
height: 300px;
background-color: yellow;
}
.absolute_c {
position: absolute;
width: 100px;
height: 100px;
background-color: blue;
margin-top: 100px;
/*๋ถ๋ชจ ์์๋ ์ด๋ํ์ง ์๊ณ ์์๋ง ์ด๋: ๋ง์ง ๋ณํฉ ํ์ X*/
top: 100px;
/*์์์์๊ฐ ๋ธ๋ผ์ฐ์ ์ต์๋จ ๊ธฐ์ค์ผ๋ก 100px ๋งํผ ์๋๋ก ์ด๋:
top~bottom ์ ์ฉ ๋ถ๊ฐ(๋ถ๋ชจ๊ฐ static์ผ ๊ฒฝ์ฐ)
๊ทธ๋ฌ๋, top~bottom ์ ์ฉ ๊ฐ๋ฅํ ๊ฒฝ์ฐ๋
(๋ถ๋ชจ๊ฐ relative์ผ ๊ฒฝ์ฐ)
๋ถ๋ชจ์ position ์ํ์ ๋ฐ๋ผ ์ขํ ๊ธฐ์ค์ ์ด ๋ฌ๋ผ์ง.*/
}
</style>
z-์ถ์ด๋?
์ด๋ค ์์๊ฐ ๋ ์์ผ๋ก ๋์์๋ ์ง ์ค์ ํ๋ ์์ฑ์ด๋ค. ์ฆ, 3์ฐจ์์ธ ๋ ์ด์ด์ธต์ ๋ง๋ ๋ค๋ ์๋ฏธ์ด๊ธฐ๋ ํ๋ค. ์ฆ, position์ด 3์ฐจ์์ผ ๊ฒฝ์ฐ(absolute์ fixed, ๊ทธ๋ฆฌ๊ณ relative)์๋ง ์ ์ฉํ ์ ์๋ค.
<style>
.z-index-1 {
position: absolute;
width: 100%;
height: 300px;
/* ํ๋์ ๋ถ๋ถ์ ์์ ์์นํจ:
๋ ์ด์ด ์ธต์ด ๊ฒน์น๊ฒ ๋๋ค.*/
background-color: yellow;
/*ํ๋์ ๋ฐ์ค์ ์๋ก ์์นํ๊ฒ ํ๊ณ ์ถ๋ค๋ฉด?*/
z-index: 100; /* ๋จ์ ์๋ต*/
}
.z-index-2 {
position: absolute;
width: 100%;
height: 200px;
/*๋
ธ๋์ ๋ถ๋ถ์ ์์ ์์นํจ:
๋์ค์ absolute๊ฐ ์์ฑ๋ z์ถ์ ์ฐ์ ์์๊ฐ ๋ ๋๋ค๋ ๊ฑธ ์ ์ ์๋ค.*/
background-color: blue;
z-index: 50px;
/* ๋
ธ๋์ ๋ถ๋ถ์ z-index ๊ฐ์ด ๋ ํผ. ์ฐ์ ์์๋ฅผ ์ ํ๋ค. */
}
</style>
์ด๊ฒ์ ์น์ฌ์ดํธ๋ฅผ ๋ง๋ค ๋ ์์๋๋ฉด ์ข์ ํ์ด๋ค.
- background-size: ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง์ ํฌ๊ธฐ๋ฅผ ์ ํ๋ค. (์์ฑ๊ฐ: contain, cover)
contain: ๊ณต๊ฐ์ ๋ฒ์ด๋์ง ์๋ ์ต๋์ ํฌ๊ธฐ๋ก ํ๋ ํน์ ์ถ์
(์ด๋ฏธ์ง๋ฅผ ์จ์ ํ๊ฒ ๋ฃ์ผ๋ผ๋ ์๋ฏธ, ๊ฐ๋ก์ธ๋ก ๋น์จ์ ์ ์ง๊ฐ ๋จ)
cover: ๊ณต๊ฐ์ ๋ฒ์ด๋๋ ๊ฝ ์ฑ์์ ํ๋ํ๊ฑฐ๋ ์ถ์
(๊ฐ๋ก์ธ๋ก ๋น์จ์ด ์ ์ง๋๋ค. ๋ณดํต์ ๊ฒฝ์ฐ, ์ด ์์ฑ๊ฐ์ ๋ง์ด ์ฌ์ฉํ๋ค.
- background-attachment: ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง์ ์คํฌ๋กค ์ฌ๋ถ๋ฅผ ๊ฒฐ์
scroll: ๋ด์ฉ์ ์คํฌ๋กค ๋๋ ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง๋ absolute.
fixed: ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง๋ fixed, ์์ ์๋ ๋ด์ฉ๋ฌผ๋ง ์คํฌ๋กค ๋จ.
์ฝ๋ ์
<style>
.bgSize {
width: 400px;
height: 400px;
background: yellow url("img/intro/1.png") center no-repeat;
background-size: cover;
/*cover: ํ๋ฉด์ ์ ๋ถ ๋ฎ์.
contain: ์ด๋ฏธ์ง๊ฐ ํ๋ฉด์ ๋์ด๊ฐ์ง ์๊ฒ ์ฑ์*/
}
body {
background: url("img/main/player1.png") no-repeat;
background-attachment: fixed;
/* fixed: ๋ฐฐ๊ฒฝ์ fixed. ๋ด์ฉ์ ์คํฌ๋กค */
/* scroll: ๋ฐฐ๊ฒฝ๊ณผ ๋ด์ฉ์ด ๊ฐ์ด ์คํฌ๋กค ๋๋ค. */
}
</style>
์น์ฌ์ดํธ ์ ๋ ฌ ์์ ์ ํ ๋, x์ถ์ด๋ y์ถ์ ์ค์ ์ ๋ ฌํ ๊ฒฝ์ฐ๊ฐ ๋ง๋ค.
<style> element { top: 45%; /* top์์ 45%๋งํผ ๋ด๋ฆผ*/ transform: translateY(-50); /* y์ถ์ผ๋ก ์์์ ํฌ๊ธฐ๋ฅผ ๊ธฐ์ค์ผ๋ก ๋ช% ํน์ ๋ช px๋งํผ ์์ง์ด๊ฒ ๋ค.*/ } </style>
์์ ๋ ๊ฐ์ง ์์ฑ์ ์ฌ์ฉํ์ฌ ์ ์ฉํ ์ ์๋ค.
top~bottom ์์ฑ์ ์ ์ฉํ ์ ์๋ 3์ฐจ์ ์์์๋ง(absolute, fixed, relative) ์ด ์์ฑ์ >์ ์ฉํ ์ ์๋ค.
์ฃผ์์ : ํฌ๋กฌ ๋ธ๋ผ์ฐ์ ํ์ ๋ฒ์ (v.7,v.8)์ผ ๊ฒฝ์ฐ, ์ ์ฉ์ด ์๋ ์๋ ์์
<script src='๊ฒฝ๋ก/full clip.js'></script>
๋ฐฐ๊ฒฝ์ด๋ฏธ์ง๊ฐ ์๋์ผ๋ก ๋กค๋ง๋๋ ํจ๊ณผ๋ฅผ ๊ตฌํํ ์ ์๋ค.
์ฉ๋์ด ์์, ์น์ฌ์ดํธ ๋ก๋ฉ ์๋ ๋ถ๋ด์ ๋ ์ ์๋ค.
full-clip ์ ๊ณต ๊ณต์ ๊นํ ์ฌ์ดํธ
๋จ, ์ด ์ฝ๋๋ฅผ ์ ๋ ฅํ๊ธฐ ์ , JQueryํ์ผ์ด ์ฐ๋๋์ด ์์ด์ผ ํ๋ค.
์๋์ ์ฝ๋๋ฅผ ์๋ ฅํ์ฌ, JQuery ๋ฐ ์๋ฐ์คํฌ๋ฆฝํธ์ ์ฐ๋ํ๋ค.
<script>
$('.fullBg').fullClip
({
images: [
'images/house.jpg',
'images/road.jpg',
'images/winter.jpg'
],
transitionTime: 1000,
wait: 7000
});
</script>
ํน์ ํ ์์์ fullClip ๋ฉ์๋์ ์ธ์๋ก ๋กค๋งํ ์ด๋ฏธ์ง ๊ฐ์ฒด๋ค์ ๊ฒฝ๋ก๋ฅผ ๋๊ฒจ์ค๋ค. ์ด๋ฏธ์ง ์ ํ ์๊ฐ๋ ์ค์ ํ๊ณ , ๋๊ธฐ ์๊ฐ ๋ํ ์ง์ ํ๋ค.
<style>
fullBg {
background-position: center center;
background-attachment: fixed;
background-size: cover;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
</style>
์์ CSS style์ ์ ์ฉํ๋ ๊ฒ๋ ์์ง ๋ง์์ผ ํ๋ค.
๋ณธ๊ฒฉ์ ์ผ๋ก ์น ์ฌ์ดํธ๋ฅผ ์ ์ํ๊ธฐ ์ , Default CSS๋ฅผ ์ ์ฉํ์ฌ ์์ฑ์ ์ด๊ธฐํ ํ๋ ๊ฒ์ด ์ข๋ค.
/*Default CSS*/
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
/*๊ณต๊ฐ์ ํฌ๊ธฐ๋ ๊ทธ๋๋ก ์ ์ง๊ฐ ๋์ง๋ง, ํจ๋ฉ ๊ฐ๋ง ์ ์ฉ์ด ๋๋ค.*/
}
</style>
๋ง๋ ํ์ด์ง๊ฐ ๋ชจ๋ฐ์ผ์์๋ ๋ฐ์ํ ์น ๋ ์ด์์์ผ๋ก ์ ๋์ํ๋ ์ง ํ์ธํ๊ธฐ ์ํด์ ํฌ๋กฌ ๋ธ๋ผ์ฐ์ ๋ฅผ ๊ธฐ์ค์ผ๋ก ๊ฒฐ๊ณผ๋ฌผ์ ์๋ฒ์ ๋ฑ๋กํ์ฌ ์ํ๋ ๊ธฐ๊ธฐ๋ก ๋๋ฉ์ธ ์ฃผ์๋ฅผ ์ ๋ ฅํ์ฌ ํ์ธํ๋ ๊ฒ์ด ๊ฐ์ฅ ์ ํํ๋ค.
๊ทธ๋ฌ๋, ๋งค๋ฒ ๊ทธ๋ ๊ฒ ํ์ธํ๋ ๊ฒ์ ๋ฒ๊ฑฐ๋ก์ฐ๋ฏ๋ก, ๊ฐ๋ฐ์ ๋๊ตฌ์ ์ผ์ชฝ ์ ๋ ๋ชจ๋ฐ์ผ ํ๋ฉด ์ฒดํฌ ๋ฒํผ์ ํ์ฉํ ์๋ ์๋ค.
Continuing on the next post...