overflow
์์์ ๋ฐ์ค์ ์ฝํ ์ธ ๊ฐ ๋์น ๋ ํํ ๋ฐฉ๋ฒ์ ์ง์ ํ๋ค. ์์ฑ๊ฐ์ ํ๋ ๋๋ ๋๊ฐ๋ฅผ ์ง์ ํ ์ ์์ผ๋ฉฐ, ๋๊ฐ๋ฅผ ์ง์ ํ ๊ฒฝ์ฐ ์ฒซ๋ฒ์งธ ๊ฐ์ overflow-x ๋๋ฒ์งธ ๊ฐ์ overflow-y๋ฅผ ์ง์ ํ๋ค. ํ๋๋ฅผ ์ง์ ํ ๊ฒฝ์ฐ ์ ์ถ ๋ชจ๋ ์ง์ ํ๋ค.
| visivle | ๋์น๋ ์ฝํ ์ธ ๋ฅผ ์๋ฅด์ง ์๊ณ ์์์ ๋ฐ์ค๋ฅผ ๋์ด ํ์ํ๋ค.(๊ธฐ๋ณธ๊ฐ) |
| hidden | ๋์น๋ ์ฝํ ์ธ ๋ฅผ ์๋ฅด๊ณ ๋ณด์ด์ง ์๊ฒํ๋ค. |
| scroll | ๋์น๋ ์ฝ์ฒธ์ธ ๋ฅผ ์๋ฅด๋ฉฐ, ํญ์ ์คํฌ๋กค๋ฐ๋ฅผ ํ์ํ๋ค. |
| auto | ๋์น์ง ์์ผ๋ฉด ์คํฌ๋กค๋ฐ๊ฐ ๋ณด์ด์ง ์์ผ๋ฉฐ ๋์น๋ฉด ์ฝ์ฒธ์ธ ๋ฅผ ์๋ฅด์ง๋ง ์คํฌ๋กค๋ฐ๊ฐ ํ์๋๋ค. |
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style type="text/css">
.box {
width: 150px;
height: 150px;
padding: 10px;
margin: 50px;
border:2px dotted gray;
}
.visible{
overflow: visible;
}
.hidden{
overflow: hidden;
}
.scroll{
overflow: scroll;
}
.auto{
overflow: auto;
}
</style>
</head>
<body>
<h3>overflow : ์์์ ๋ฐ์ค์ ์ฝํ
์ธ ๊ฐ ๋์น ๋ ํํ๋ฐฉ๋ฒ์ ์ง์ </h3>
<div class="box">
<h3>default</h3>
html css javascript jquery node.js react vue.js java oracle mysql bigdata maven spring spring-security mybatis
</div>
<div class="box visible">
<h3>visible</h3>
html css javascript jquery node.js react vue.js java oracle mysql bigdata maven spring spring-security mybatis
</div>
<div class="box hidden">
<h3>hidden</h3>
html css javascript jquery node.js react vue.js java oracle mysql bigdata maven spring spring-security mybatis
</div>
<div class="box scroll">
<h3>scroll</h3>
html css javascript jquery node.js react vue.js java oracle mysql bigdata maven spring spring-security mybatis
</div>
<div class="box auto">
<h3>auto</h3>
html css javascript jquery node.js react vue.js java oracle mysql bigdata maven spring spring-security mybatis
</div>
</body>
</html>

resize
์์์ ํฌ๊ธฐ๋ฅผ ์กฐ์ ํ ์ ์๋์ง ์ฌ๋ถ์ ๋ฐฉํฅ์ ๊ฒฐ์ ํ๋ค.

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style type="text/css">
.box {
width: 150px;
height: 150px;
padding: 10px;
margin: 30px;
border:2px dotted gray;
overflow: hidden; /*div๊ฐ resize๊ฐ ๊ฐ๋ฅํ๋๋ก ํ๊ธฐ ์ํด์๋ hidden๋๋ auto*/
}
.ta{width: 150px; height: 150px; padding: 10px; margin: 50px;}
.b{resize: both;}
.h{resize: horizontal;}
.v{resize: vertical;}
.n{resize: none;}
</style>
</head>
<body>
<h3>resize : ์์์ ํฌ๊ธฐ๋ฅผ ์กฐ์ ํ ์ ์๋์ง ์ฌ๋ถ์ ๋ฐฉํฅ์ ๊ฒฐ์ </h3>
<div class="box"><h3>default</h3></div>
<div class="box b"><h3>both</h3></div>
<div class="box h"><h3>horizontal</h3></div>
<div class="box v"><h3>vertical</h3></div>
<textarea class="ta">default</textarea>
<textarea class="ta n">none</textarea>
</body>
</html>

opacity
์์์ ๋ถํฌ๋ช ๋๋ฅผ ์ค์ ํ๋ค. ๋ถํฌ๋ช ๋๋ ์์ ๋ค์ชฝ ์ฝํ ์ธ ๊ฐ ์จ๊ฒจ์ง๋ ์ ๋๋ก, ํฌ๋ช ๋์ ๋ฐ๋์ด๋ค.
0: ์์๊ฐ ์์ ํ ํฌ๋ช ํด ๋ณด์ด์ง ์์ 0๋ณด๋ค ํฌ๊ณ 1๋ณด๋ค ์ ์ ๊ฐ : ์์๊ฐ ๋ฐ์ถ๋ช ํด ๋ค์ ๊ฐ์ ๋ณผ ์ ์์. ๊ฐ์ด ์์์๋ก ์ ์๋ณด์ 1:๊ธฐ๋ณธ๊ฐ ๋ถํฌ๋ช ํจ
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style type="text/css">
.box {
width: 150px;
height: 150px;
padding: 10px;
margin: 30px;
border:2px dotted gray;
background: orange;
}
.light{opacity: 0.2;}
.medium{opacity: 0.5;}
.heavy{opacity: 0.9;}
</style>
</head>
<body>
<h3>opacity : ์คํจ์ํฐ๋ ์์์ ๋ถํฌ๋ช
๋๋ฅผ ์ค์ . ๋ถํฌ๋ช
๋๋ ์์ ๋ค์ชฝ ์ฝํ
์ธ ๊ฐ ์จ๊ฒจ์ง๋ ์ ๋</h3>
<div class="box">๊ธฐ๋ณธ๊ฐ</div>
<div class="box light">๋ฐฐ๊ฒฝ ์๋ก ๊ฒจ์ฐ ๋ณผ ์ ์์</div>
<div class="box medium">๋ฐฐ๊ฒฝ ์๋ก ์กฐ๊ธ ๋ ์ ๋ณด์</div>
<div class="box heavy">๋ฐฐ๊ฒฝ ์๋ก ๋๋ ทํ๊ฒ ๋ณด์</div>
</body>
</html>

margin
์์์ ๋ค ๋ฐฉํฅ ๋ฐ๊นฅ ์ฌ๋ฐฑ ์์ญ์ ์ค์ ํ๋ฉฐ,'์ฌ๋ฐฑ'์ ํ๊ฐ์์ ๋ค๊ฐ๊น์ง ์ค์ ๊ฐ๋ฅํ๋ค.

padding
์์์ ๋ค ๋ฐฉํฅ ์์ชฝ ์ฌ๋ฐฑ ์์ญ์ ์ค์ ํ๋ฉฐ, '์ฌ๋ฐฑ'์ ํ ๊ฐ์์ ๋ค ๊ฐ๊น์ง ์ค์ ๊ฐ๋ฅํ๋ค.

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style type="text/css">
.box {
width: 200px;
border:2px dotted gray;
}
.orange{background: #f60;}
.yellow{background: #ff0;}
.green{background: #0f0;}
.h{height: 100px;}
.p{padding: 1px;}
.m{margin: 20px;}
.b{border: 1px solid rgba(0,0,0,0);}
</style>
</head>
<body>
<h3>๋ง์ง ๊ฒน์นจ(๋ง์ง ์์) ํ์</h3>
<pre>
- top ๋ฐ bottom ๋ง์ง์ ๊ฐ์ฅ ํฐ ํ ๋ง์ง์ผ๋ก ๊ฒฐํฉ(combine, ์์(collapsed))๋๋ค.
- ๋ง์ง ๊ฒน์นจ์ ์ด๋ค ๋ ๊ฐ ์ด์ ๋ธ๋ก ์์์ ์ํ ๋ง์ง์ด ๊ฒน์น ๋ ์ด๋ ํ ์ชฝ์ ๊ฐ๋ง ์ ์ฉ
- ๋ง์ง ๊ฒน์นจ์ ์ธ์ ํ ๋ ๋ฐ์ค๊ฐ ์จ์ ํ block-level ์์์ผ ๊ฒฝ์ฐ์ ๋ฐ์ํ๋ค.
- ๋ง์ง ๊ฐ์ด 0์ด๋๋ผ๋ ๊ฒน์นฉ์ ์ ์ฉ๋๋ค.
- ์ข์ฐ ๋ง์ง์ ๊ฒน์น๋๋ผ๋ ์์๋์ง ์๋๋ค.
- ๋ง์ง ๊ฒน์นจ์ด ์ผ์ด๋๋ ๊ฒฝ์ฐ
์ธ์ ํ์ ์ ์ํ ๋ง์ง์ด ๊ฒน์น ๋, ๋น ์์(height๊ฐ 0์ธ๊ฒฝ์ฐ)์ ์ํ ๋ง์ง์ด ๊ฒน์น ๋, ๋ถ๋ชจ ๋ฐ์ค์ ์ฒซ ๋ฒ์งธ(๋ง์ง๋ง) ์์ ๋ฐ์ค์ ์๋จ(ํ๋จ) ๋ง์ง์ด ๊ฒน์น ๋
- ๋ง์ง ๊ฒน์นจ์ ์ธ์ ํ ๋ ๋ฐ์ค๊ฐ ์จ์ ํ block-level ์์์ผ ๊ฒฝ์ฐ์๋ง ์ ์ฉ
- ๋ง์ง ๊ฒน์นจ์ ๋ง์ผ๋ ค๋ฉด ๋ถ๋ชจ ๋ฐ์ค ์๋จ(ํ๋จ)์ padding ๋๋ border ๊ฐ์ ์ฃผ์ด ๋ฒฝ์ ๋ง๋ค์ด์ฃผ๋ ๊ฒ์ด ์์
</pre>
<!-- ์ข์ฐ๋ ๋ชจ๋ margin์ด ์ ์ฉ๋์ง๋ง ์ํ๋ ํ๋ฒ๋ง margin์ด ์ ์ฉ ๋จ -->
<div class="box">
<div class="orange m">
<div class="yellow m">
<div class="green m h">A</div>
</div>
</div>
</div>
<hr>
<!-- padding์ผ๋ก ๋ฌธ์ ํด๊ฒฐ -->
<div class="box">
<div class="orange m p">
<div class="yellow m p">
<div class="green m h p">B</div>
</div>
</div>
</div>
<hr>
<!-- border๋ก ๋ฌธ์ ํด๊ฒฐ -->
<div class="box">
<div class="orange m b">
<div class="yellow m b">
<div class="green m h b">C</div>
</div>
</div>
</div>
<hr>
<!-- display: inline-block; ์ผ๋ก ๋ฌธ์ ํด๊ฒฐ -->
<div class="box" style="display: inline-block;">
<div class="orange m" style="display: inline-block;">
<div class="yellow m" style="display: inline-block;">
<div class="green m h" style="display: inline-block;">D</div>
</div>
</div>
</div>
<hr>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style type="text/css">
.box {
width: 100px;
height: 50px;
border:3px dotted gray;
}
.m1{margin-bottom: 30px;}
.m2{margin-bottom: 15px;}
.m3{margin-top: 15px;}
</style>
</head>
<body>
<h3>๋ง์ง ๊ฒน์นฉ(๋ง์ง ์์) ํ์</h3>
<div class="box m1"></div>
<div class="box"></div>
<hr>
<!-- ์ด๋ฐ ๊ฒฝ์ฐ์๋ ์ฒซ๋ฒ์งธ margin-bottom์ ์กฐ์ ํ๊ฑฐ๋, inline-block์ผ๋ก ์ค์ ํ๋ค. -->
<div class="box m2"></div>
<div class="box m3"></div>
<hr>
</body>
</html>

flaot
ํด๋น ์์๋ฅผ ์์ ์ ๊ฐ์ธ๊ณ ์๋ ์ปจํ ์ด๋์ ์ผ์ชฝ์ด๋ ์ค๋ฅธ์ชฝ์ ๋ฐฐ์นํ๋๋ก ์ค์

- clear ์์ฑ : ์ค์ ๋ float ์์ฑ์ ํด์ ํ๋ค.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style type="text/css">
*{box-sizing: border-box;}
.p-box{margin-top: 20px;}
.box{width: 50px;height: 50px; padding: 10px;
border: 3px solid gray;
text-align: center;
}
.left{float: left;}
.clear:after{
content:'';
display:block;
clear:both;
}
</style>
</head>
<body>
<h3>float ํด์ </h3>
<div class="p-box">
<div class="box left">A</div>
<div class="box left">B</div>
</div>
<div class="p-box">
<div class="box left">C</div>
<div class="box left">D</div>
</div>
<div style="clear: both;"></div>
<hr>
<p> ๋ถ๋ชจ์ ๊ฐ์ ๋ก height ์์ฑ์ ์ฃผ๋ฉด float ์์ฑ์ด ํด์ . ๋ฐ์ํ์ ์๋ ๋์ด ๋ถ๊ฐ. </p>
<div class="p-box" style="height: 55px;">
<div class="box left">A</div>
<div class="box left">B</div>
</div>
<div class="p-box" style="height: 55px;">
<div class="box left">C</div>
<div class="box left">D</div>
</div>
<hr>
<p> clear:both;๋ margin-top์ด ์ ์ฉ๋์ง ์๋๋ค. </p>
<div class="p-box">
<div class="box left">A</div>
<div class="box left">B</div>
</div>
<div class="p-box" style="clear:both; margin-top: 20px;">
<div class="box left">C</div>
<div class="box left">D</div>
</div>
<div style="clear: both;"></div>
<hr>
<p> float๋ ์์์ ๋ถ๋ชจํ๊ทธ์ overflow:hidden์ผ๋ก float ํด์ </p>
<div class="p-box" style="overflow: hidden;">
<div class="box left">A</div>
<div class="box left">B</div>
</div>
<div class="p-box" style="overflow: hidden;">
<div class="box left">C</div>
<div class="box left">D</div>
</div>
<hr>
<p> float๋ ์์์ ๋ถ๋ชจํ๊ทธ์ ๊ฐ์์์๋ฅผ ๋ง๋ค๊ณ ํด๋น ์์์ clear:both๋ฅผ ์ง์ (๊ถ์ฅ) </p>
<div class="p-box clear">
<div class="box left">A</div>
<div class="box left">B</div>
</div>
<div class="p-box clear" style="margin-top: 20px;">
<div class="box left">C</div>
<div class="box left">D</div>
</div>
<hr>
</body>
</html>

Position
๋ฌธ์ ์์ ์์๋ฅผ ๋ฐฐ์นํ๋ ๋ฐฉ๋ฒ์ ์ง์ ํ๋ค.
| static | ์ผ๋ฐ์ ์ธ ๋ฌธ์ ํ๋ฆ์ ๋ฐ๋ผ ๋ฐฐ์น (๊ธฐ๋ณธ๊ฐ, ์์น ์ง์ ๋ถ๊ฐ) |
| relative | ์ผ๋ฐ์ ์ธ ๋ฌธ์ ํ๋ฆ์ ๋ฐ๋ผ ๋ฐฐ์นํ๋ฉฐ, ์์น๋ฅผ ์ง์ ํ ์ ์๋ค. |
| absolute | ๋ฌธ์์ ์ผ๋ฐ์ ์ธ ํ๋ฆ์ ๋ฐ๋ฅด์ง ์๊ณ , ํ์ด์ง ๋ ์ด์์์ ๊ณต๊ฐ๋ ๋ฐฐ์ ํ์ง ์๋๋ค. |
| fixed | ๋ฌธ์์ ์ผ๋ฐ์ ์ธ ํ๋ฆ์ ๋ฐ๋ฅด์ง ์๊ณ , ํ์ด์ง ๋ ์ด์์์ ๊ณต๊ฐ๋ ๋ฐฐ์ ํ์ง ์๋๋ค. ์คํฌ๋กค์ด ๋๋๋ผ๋ ํ๋ฉด์์ ์ฌ๋ผ์ง์ง ์๊ณ ํญ์ ๊ฐ์ ๊ณณ์ ์์นํจ. |
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style type="text/css">
.box{
width: 150px; height: 150px;
margin: 30px;
border: 3px dotted gray;
background: orange;
}
.relative-box{
position:relative;
left:50px;
top:50px;
background: #333;
color: #eee;
font-weight: bold;
text-align: center;
line-height: 150px;
}
</style>
</head>
<body>
<h3>position:relative - ์ผ๋ฐ์ ์ธ ๋ฌธ์ ํ๋ฆ์ ๋ฐ๋ผ ๋ฐฐ์นํ๋ฉฐ, ์์น๋ฅผ ์ง์ ํ ์ ์๋ค.</h3>
<div class="box"><div class="relative-box">parent-div</div></div>
<div class="relative-box">parent-body</div>
</body>
</html>

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style type="text/css">
.box {
width: 150px;
height: 150px;
margin: 50px 0 0 300px;
border: 3px dotted gray;
background: orange;
position: relative;
}
.absolute-box {
position: absolute;
left: 50px;
top: 50px;
/*
๋ถ๋ชจ์ ํฌ์ง์
์ด static์ด๋ฉด ๊ธฐ์ค์ ์ body์ด๊ณ
๋ถ๋ชจ์ ํฌ์ง์
์ด relative์ด๋ฉด ๊ธฐ์ค์ ์ ๋ถ๋ชจ์ด๋ค.
*/
width: 150px;
height: 150px; background : #333;
color: #eee;
font-weight: bold;
text-align: center;
line-height: 150px;
background: #333;
}
</style>
</head>
<body>
<h3>position:absolute - ์์๊ฐ ๋ฌธ์์ ์ผ๋ฐ์ ์ธ ํ๋ฆ์ ๋ฐ๋ฅด์ง ์๊ณ , ํ์ด์ง ๋ ์ด์์์ ๊ณต๊ฐ๋
๋ฐฐ์ ํ์ง ์๋๋ค.</h3>
<div class="box">
<div class="absolute-box">parent-div</div>
<!--absolute-box parent-div์ ๊ธฐ์ค์ body -->
</div>
<div class="absolute-box">parent-body</div>
<p>HTML, CSS, Javascript</p>
</body>
</html>

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style type="text/css">
.box{
width: 100%; height: 1500px; background: yellow;
}
.fixed-box{
width: 150px; height: 150px;
position: fixed;
left: 100px;
top: 200px;
border: 3px dashed gray;
background: orange;
color: #ccc;
font-weight: bold; text-align: center; line-height: 150px;
}
</style>
</head>
<body>
<h3>position:fixed </h3>
<div class="box">
์์๊ฐ ๋ฌธ์์ ์ผ๋ฐ์ ์ธ ํ๋ฆ์ ๋ฐ๋ฅด์ง ์๊ณ , ํ์ด์ง ๋ ์ด์์์ ๊ณต๊ฐ๋ ๋ฐฐ์ ํ์ง ์๋๋ค.<br>
๋ถ๋ชจ ์์์ ๊ด๊ณ์์ด ๋ธ๋ผ์ฐ์ ์ viewport๋ฅผ ๊ธฐ์ค์ผ๋ก ์ขํ ํ๋กํผํฐ(top, bottom, left, right)์
์ฌ์ฉํ์ฌ ์์น๋ฅผ ์ด๋์ํจ๋ค.<br>
์คํฌ๋กค์ด ๋๋๋ผ๋ ํ๋ฉด์์ ์ฌ๋ผ์ง์ง ์๊ณ ํญ์ ๊ฐ์ ๊ณณ์ ์์นํ๋ค.
</div>
<div class="fixed-box">fixed-box</div>
</body>
</html>

'๐ป > CSS' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
| (45) [CSS] 3์ผ ๋ฐ์ํ ์น(Responsive Web) (1) | 2024.04.18 |
|---|---|
| (45) [CSS] 3์ผ ๋ ์ด์์๊ณผ ํฌ์ง์ ๋ - Grid (0) | 2024.04.18 |
| (44) [CSS] 2์ผ ๋ ์ด์์๊ณผ ํฌ์ง์ ๋ - flex (0) | 2024.04.17 |
| (43) [CSS] 1์ผ ํ ์คํธ ๋ฐ ๋ฐฐ๊ฒฝ ๊ด๋ จ ์คํ์ผ (0) | 2024.04.16 |
| (43) [CSS] 1์ผ CSS ๊ธฐ์ด (0) | 2024.04.16 |