<style>
.parent-static{
width: 300px;
/* height: 300px; -3*/
background-color: antiquewhite;
}
.child-static{
position: static;
width: 100px;
height: 100px;
background-color: blueviolet;
/* margin-top: 100px; -1)*/
/* top: 100px; -2)*/
}
</style>
position: static
-๊ธฐ๋ณธ๊ฐ(์ค์ ํ์ง ์์๋ ๊ธฐ๋ณธ ์ ์ฉ)
-2์ฐจ์ ์์ฑ -> float ์ฌ์ฉํ๋ฉด ์์น ์ง์ ๊ฐ๋ฅ
3๊ฐ์ง ์ฒดํฌ ์ฌํญ
1) ๋ถ๋ชจ ์์ ๊ฐ ๋ง์ง ๋ณํฉ? ๋ง์ง ๋ณํฉ ๋ฐ์
2) top, right, bottom, left ์์ฑ ์ฌ์ฉ ๊ฐ๋ฅ? ์ฌ์ฉ๋ถ๊ฐ
3) ์์ ๋์ด๊ฐ ๋ถ๋ชจ ๋์ด์ ์ํฅ? ์ํฅ์ ์ค๋ค
<body>
<div class="parent-static">
<div class="child-static"></div>
</div>
</body>
<style>
.box1{
width: 300px;
height: 300px;
background-color: palegreen;
}
.parent-fixed{
width: 300px;
/* height: 300px;)*/
background-color: antiquewhite;
}
.child-fixed{
position: fixed;
width: 100px;
height: 100px;
background-color: blueviolet;
/* margin-top: 100px;*/
/* top:100px;*/
}
.box2{
width: 300px;
height: 300px;
background-color: pink;
}
</style>
position: fixed
-top ๋ฒํผ, ์คํฌ๋กคํด๋ ๋ด๋ ค์ค๋ ๋ฉ๋ด
-3์ฐจ์ ์์ฑ
3๊ฐ์ง ์ฒดํฌ ์ฌํญ
1) ๋ถ๋ชจ ์์ ๊ฐ ๋ง์ง ๋ณํฉ? ๋ฐ์ํ์ง ์์
2) top, right, bottom, left ์์ฑ ์ฌ์ฉ ๊ฐ๋ฅ? ์ฌ์ฉ๊ฐ๋ฅ-๊ธฐ์ค์ ๋ธ๋ผ์ฐ์
3) ์์ ๋์ด๊ฐ ๋ถ๋ชจ ๋์ด์ ์ํฅ? ์ํฅ ์์
<body>
<div class="box1"></div>
<div class="parent-fixed">
<div class="child-fixed"></div>
</div>
<div class="box2"></div>
</body>
<style>
.box1{
width: 300px;
height: 300px;
background-color: palegreen;
}
.parent-relative{
width: 300px;
/* height: 300px; */ /*3*/
background-color: antiquewhite;
}
.child-relative{
position: relative;
width: 100px;
height: 100px;
background-color: blueviolet;
/* margin-top: 100px;*/ /*1*/
/*top:100px;*/ /*2*/
}
.box2{
width: 300px;
height: 300px;
background-color: pink;
}
</style>
position: relative
-ํฐ ๋ ์ด์์ ์์ฑ์์ ์์ฃผ ์ฌ์ฉ
3๊ฐ์ง ์ฒดํฌ ์ฌํญ
1) ๋ถ๋ชจ ์์ ๊ฐ ๋ง์ง ๋ณํฉ? ๋ฐ์ํ์ง ์์
2) top, right, bottom, left ์์ฑ ์ฌ์ฉ ๊ฐ๋ฅ? ์ฌ์ฉ๊ฐ๋ฅ-๊ธฐ์ค์ ๋ธ๋ผ์ฐ์
3) ์์ ๋์ด๊ฐ ๋ถ๋ชจ ๋์ด์ ์ํฅ? ์ํฅ ์์
<body>
<div class="box1"></div>
<div class="parent-relative">
<div class="child-relative"></div>
</div>
</body>
<style>
.box1{
width: 300px;
height: 300px;
background-color: palegreen;
}
.parent-absolute{
width: 300px;
height: 300px;
background-color: antiquewhite;
/* ์ขํ(top) ์ฌ์ฉ์ ์ด๋ ๊ธฐ์ค์ ๋ธ๋ผ์ฐ์ -> ์ ์์น ๋ฐ๊พธ๊ณ ์ถ์ ๋ ๋ถ๋ชจ์์์ position:relative๋ก ๋ง๋ ๋ค */
position: relative;
}
.child-absolute{
position: absolute;
width: 100px;
height: 100px;
background-color: blueviolet;
margin-top: 100px;
/* top:100px; 2 */
}
</style>
position: absoulute
-ํฐ ๋ ์ด์์ ์์ฑ์์ ์์ฃผ ์ฌ์ฉ
3๊ฐ์ง ์ฒดํฌ ์ฌํญ
1) ๋ถ๋ชจ ์์ ๊ฐ ๋ง์ง ๋ณํฉ? ๋ฐ์ํ์ง ์์
2) top, right, bottom, left ์์ฑ ์ฌ์ฉ ๊ฐ๋ฅ? ์ฌ์ฉ๊ฐ๋ฅ-๊ธฐ์ค์ ๋ธ๋ผ์ฐ์
3) ์์ ๋์ด๊ฐ ๋ถ๋ชจ ๋์ด์ ์ํฅ? ์ํฅ ์์
<body>
<div class="box1"></div>
<div class="parent-absolute">
<div class="child-absolute"></div>
</div>
</body>
<style>
.box1{
width: 100px;
height: 300px;
background-color: aquamarine;
position: absolute;
z-index: 1;
}
.box2{
width: 200px;
height: 100px;
background-color: yellow;
position: absolute;
/* z-index: 2; */
}
</style>
<body>
<div class="box1"></div>
<div class="box2"></div>
</body>
<style>
body{
width: 100%;
}
.left{
width: 300px;
height: 300px;
background-color: antiquewhite;
float: left;
/* overflow: hidden; */
overflow-x: scroll;
overflow-y: scroll;
}
.left-2{
width: 100px;
height: 300px;
background-color: blue;
float: left;
}
.right{
width: 300px;
height: 300px;
background-color: red;
float: right;
}
.right-2{
width: 100px;
height: 300px;
background-color: green;
float: right;
}
.clearfix{
clear: both;
/* float ์ฌ์ฉ ํด์ ๋ฅผ ๋ช
ํํ ํ์ -> ๋น ๋ฅธ ์ฝ๋ ํ์ธ ๊ฐ๋ฅ */
}
footer{
width: 100%;
height: 100px;
background-color: black;
/* clear: left | right | both */
}
</style>
<body>
<div class="left">
<p>
Lorem ipsum dolor sit amet consectetur, adipisicing elit.
Consequatur dolorum quasi quo eius explicabo nam ad praesentium provident,
non magnam possimus maiores dicta. Iure tenetur magni deleniti quasi. Dolor, dicta!
Lorem ipsum dolor sit amet consectetur, adipisicing elit
Lorem ipsum dolor sit amet consectetur, adipisicing elit
Lorem ipsum dolor sit amet consectetur, adipisicing elit
Lorem ipsum dolor sit amet consectetur, adipisicing elit
</p>
</div>
<div class="left-2"></div>
<div class="right"></div>
<div class="right-2"></div>
<div class="clearfix"></div>
<footer></footer>
</body>