๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐Ÿ’ป/CSS

(43) [CSS] 1์ผ ํ…์ŠคํŠธ ๋ฐ ๋ฐฐ๊ฒฝ ๊ด€๋ จ ์Šคํƒ€์ผ

by ๋”ฐ๊ถˆ 2024. 4. 16.

 

๊ธ€๊ผด 

  • font-family : ์›น ๋ฌธ์„œ์˜ ๊ธ€๊ผด์„ ์ง€์ •ํ•˜๋ฉฐ, ์‹œ์Šคํ…œ ๋‚ด ํฐํŠธ ์ด๋ฆ„ ์ค‘ ํ•˜๋‚˜๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค. 
  • Web Fonts : ์›น ํฐํŠธ๋Š” ๋กœ์ปฌ์˜ ํฐํŠธ ์„ค์น˜ ์ƒํ™ฉ์— ์ƒ๊ด€์—†์ด ์›น์—์„œ ํ•ญ์ƒ ์›ํ•˜๋Š” ํƒ€์ดํฌ๊ทธ๋ž˜ํ”ผ๋ฅผ ์‚ฌ์šฉํ• ์ˆ˜ ์žˆ๊ฒŒ ํ•˜๋Š” ๊ธฐ์ˆ ์ด๋‹ค. 
  • font-size : ํฐํŠธ์˜ ํฌ๊ธฐ๋ฅผ ์ง€์ •ํ•œ๋‹ค
  • font-weight : ํฐํŠธ์˜ ๊ตต๊ธฐ๋ฅผ ์ง€์ •ํ•œ๋‹ค. 
  • white-space : ๊ณต๋ฐฑ ์ฒ˜๋ฆฌ ๋ฐฉ๋ฒ•์„ ๊ฒฐ์ •ํ•œ๋‹ค
  • letter-spacing : ๊ธ€์ž์™€ ๊ธ€์ž ์‚ฌ์ด์˜ ๊ฐ„๊ฒฉ์„ ์ง€์ •ํ•œ๋‹ค. 
  • word-spacing : ๋‹จ์–ด์˜ ๊ฐ„๊ฒฉ์„ ์กฐ์ •ํ•œ๋‹ค. 
  • text-overflow : white-space:nowrap; ๋กœ ์ง€์ •ํ•˜์—ฌ ํ…์ŠคํŠธ๊ฐ€ ์˜์—ญ์„ ๋„˜์ณ๋„ ์ค„ ๋ฐ”๊ฟˆ์ด ์ผ์–ด๋‚˜์ง€ ์•Š์„ ๋•Œ ๋„˜์น˜๋Š” ํ…์ŠคํŠธ๋ฅผ ์ฒ˜๋ฆฌํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์ง€์ •ํ•œ๋‹ค. 

 

<!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: 3px dotted gray;
}

.normal{
	white-space: normal;
}

.nowrap{
	white-space: nowrap;
}
.pre{
	white-space: pre;
}

.pre-wrap{
	white-space: pre-wrap;
}

.pre-line{
	white-space: pre-line;
}





</style>

</head>
<body>

<h3>white-space : ํ•ด๋‹น ์š”์†Œ์˜ ๊ณต๋ฐฑ ์ฒ˜๋ฆฌ ๋ฐฉ๋ฒ•์„ ๊ฒฐ์ •ํ•œ๋‹ค.</h3>

<div class="box normal">
    <b>normal</b>
    javascript     html      css
    java     spring
    oracle    mysql 
</div>

<div class="box nowrap">
    <b>nowrap</b>
    javascript     html      css
    java     spring
    oracle    mysql 
</div>

<div class="box pre">
    <b>pre</b>
    javascript     html      css
    java     spring
    oracle    mysql 
</div>

<div class="box pre-wrap">
    <b>pre-wrap</b>
    javascript     html      css
    java     spring
    oracle    mysql 
</div>

<div class="box pre-line">
    <b>pre-line</b>
    javascript     html      css
    java     spring
    oracle    mysql 
</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;
	padding: 10px;
	margin: 30px;
	border: 3px dotted gray;
}

.ls1{letter-spacing: 3px;}
.ls2{letter-spacing: .2rem;}
.ls3{letter-spacing: -2px;}


</style>

</head>
<body>

<h3>letter-spacing : ๊ธ€์ž์™€ ๊ธ€์ž์‚ฌ์ด์˜ ๊ฐ„๊ฒฉ์„ ์กฐ์ •ํ•œ๋‹ค.</h3>

<div class="box">
<b>๊ธฐ๋ณธ๊ฐ’</b>
javascript html css
java spring
oracle mysql 
</div>

<div class="box ls1">
<b>3px</b>
javascript html css
java spring
oracle mysql 
</div>

<div class="box ls2">
<b>.2rem</b>
javascript html css
java spring
oracle mysql 
</div>

<div class="box ls3">
<b>-2px</b>
javascript html css
java spring
oracle mysql 
</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;
	padding: 10px;
	margin: 30px;
	border: 3px dotted gray;
}

.ws1{word-spacing: 10px;}
.ws2{word-spacing: 130%;}
.ws3{word-spacing: -3px;}


</style>

</head>
<body>

<h3>word-spacing : ๋‹จ์–ด์˜ ๊ฐ„๊ฒฉ์„ ์กฐ์ •ํ•œ๋‹ค.</h3>

<div class="box">
<b>๊ธฐ๋ณธ๊ฐ’</b>
javascript html css
java spring
oracle mysql 
</div>

<div class="box ws1">
<b>10px</b>
javascript html css
java spring
oracle mysql 
</div>

<div class="box ws2">
<b>130%</b>
javascript html css
java spring
oracle mysql 
</div>

<div class="box ws3">
<b>-3px</b>
javascript html css
java spring
oracle mysql 
</div>

</body>
</html>

 

 

 

 

 

๋ฐฐ๊ฒฝ 

  • background-color : ์š”์†Œ์˜ ๋ฐฐ๊ฒฝ ์ƒ‰์„ ์„ค์ •ํ•œ๋‹ค. ํ•˜๋‚˜์˜ <color>๊ฐ’์„ ์‚ฌ์šฉํ•ด ์„ค์ •ํ•œ๋‹ค. 
  • background-image : ์š”์†Œ์˜ ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง€๋ฅผ ์„ค์ •ํ•œ๋‹ค. 
  • background-repeat : ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง€๋ฅผ ์–ด๋–ป๊ฒŒ ๋ฐ˜๋ณตํ• ์ง€ ์„ค์ •ํ•œ๋‹ค. 
  • background-position : ๊ฐ ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง€์˜ ์ดˆ๊ธฐ ์œ„์น˜๋ฅผ ์„ค์ •.
  • background-size : ์š”์†Œ ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง€์˜ ํฌ๊ธฐ๋ฅผ ์„ค์ •ํ•œ๋‹ค. 
  • background-attachment : ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง€์˜ ์œ„์น˜๊ฐ€ ๋ทฐํฌํŠธ ๋‚ด์—์„œ ๊ณ ์ •๋˜๋Š”์ง€ ๋˜๋Š” ํฌํ•จํ•˜๋Š” ๋ธ”๋ก์œผ๋กœ ์Šคํฌ๋กค ๋˜๋Š”์ง€ ์—ฌ๋ถ€๋ฅผ ์„ค์ •ํ•œ๋‹ค. 

 

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style type="text/css">
.box{
	width: 300px;
	height: 300px;
	padding: 10px;
	margin: 30px;
	border: 2px dotted gray; 
}

.bg1{background-image: url("../img/bg1.png");}
.bg2{background-image: url("../img/bg1.png"); background-repeat: repeat-x;}
.bg3{background-image: url("../img/bg1.png"); background-repeat: no-repeat;}
.bg4{background-image: url("../img/bg1.png"); background-repeat: no-repeat; background-position: right center;}



</style>

</head>
<body>

<h3>background-image</h3>

<div class="box bg1">๋ฐฐ๊ฒฝ์ด๋ฏธ์ง€๊ฐ€ ์ ์œผ๋ฉด ๊ธฐ๋ณธ์ ์œผ๋กœ ๋ฐ˜๋ณตํ•œ๋‹ค.</div>
<div class="box bg2">x ์ถ• ๋ฐ˜๋ณต</div>
<div class="box bg3">๋ฐ˜๋ณตํ•˜์ง€ ์•Š์œผ๋ฉด ์ขŒ์ธก ์ตœ์ƒ๋‹จ</div>
<div class="box bg4">๋ฐ˜๋ณตํ•˜์ง€ ์•Š๊ณ  ์˜ค๋ฅธ์ชฝ ์ค‘์•™</div>

</body>
</html>

 

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style type="text/css">
.box{
	width: 300px;
	height: 300px;
	padding: 10px;
	margin: 30px;
	border: 2px dotted gray; 
}

.bg1{background: url("../img/bg1.png")no-repeat;}
.bg2{background: url("../img/bg1.png")no-repeat, url("../img/bg2.png")}
.bg3{background: url("../img/bg3.png")no-repeat left top,
				 url("../img/bg3.png")no-repeat right top,
				 url("../img/bg3.png")no-repeat left bottom,
				 url("../img/bg3.png")no-repeat right bottom;}

</style>

</head>
<body>

<h3>background</h3>

<div class="box bg1">๋ฐฐ๊ฒฝ์ด๋ฏธ์ง€</div>
<div class="box bg2">์—ฌ๋Ÿฌ๊ฐœ์˜ ๋ฐฐ๊ฒฝ์ด๋ฏธ์ง€๋ฅผ ์„ค์ •ํ•œ ๊ฒฝ์šฐ ๋จผ์ € ์„ค์ •ํ•œ ์ด๋ฏธ์ง€๊ฐ€ ์ „๋ฉด์— ๋ฐฐ์น˜</div>
<div class="box bg3">์—ฌ๋Ÿฌ๊ฐœ์˜ ๋ฐฐ๊ฒฝ์ด๋ฏธ์ง€</div>


</body>
</html>

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style type="text/css">
.box{
	width: 600px;
	height: 150px;
	margin: 30px;
	border: 2px dotted gray; 
	
	background-image: url("../img/bg4.png");
}

.bg1{background-repeat: no-repeat;}
.bg2{background-size:300px 300px;}
.bg3{background-size: 100% 100%;}
.bg4{background-size: cover;}
.bg5{background-size: contain;}


</style>

</head>
<body>

<h3>background-size</h3>

<div class="box bg1">๋ฐฐ๊ฒฝ์ด๋ฏธ์ง€</div>
<div class="box bg2">์ง€์ •๋œ px๊ฐ’ ๊ทธ๋Œ€๋กœ ์„ค์ •</div>
<div class="box bg3">์ง€์ •๋œ %๊ฐ’์— ๋น„๋ก€ํ•˜์—ฌ ์„ค์ •. ํ™”๋ฉด์„ ์ค„์ด๊ฑฐ๋‚˜ ๋Š˜๋ฆฌ๋ฉด ๋ฐฐ๊ฒฝ์ด๋ฏธ์ง€์˜ ํฌ๊ธฐ๋„ ๋”ฐ๋ผ์„œ ๋ณ€๊ฒฝ๋˜์–ด ์ฐŒ๊ทธ๋Ÿฌ์ง€๋Š” ํ˜„์ƒ์ด ๋‚˜ํƒ€๋‚œ๋‹ค.</div>
<div class="box bg4">๋ฐฐ๊ฒฝ์ด๋ฏธ์ง€์˜ ํฌ๊ธฐ ๋น„์œจ์„ ์œ ์ง€ํ•œ ์ƒํƒœ์—์„œ ๋ถ€๋ชจ ์š”์†Œ์˜ width, height ์ค‘ ํฐ๊ฐ’์— ๋ฐฐ๊ฒฝ์ด๋ฏธ์ง€๋ฅผ ๋งž์ถ˜๋‹ค. ๋”ฐ๋ผ์„œ ์ด๋ฏธ์ง€์˜ ์ผ๋ถ€๊ฐ€ ๋ณด์ด์ง€ ์•Š์„ ์ˆ˜ ์žˆ๋‹ค.</div>
<div class="box bg5">๋ฐฐ๊ฒฝ์ด๋ฏธ์ง€์˜ ํฌ๊ธฐ ๋น„์œจ์„ ์œ ์ง€ํ•œ ์ƒํƒœ์—์„œ ๋ถ€๋ชจ ์š”์†Œ์˜ ์˜์—ญ์— ๋ฐฐ๊ฒฝ์ด๋ฏธ์ง€๊ฐ€ ๋ณด์ด์ง€ ์•Š๋Š” ๋ถ€๋ถ„์—†์ด ์ „์ฒด๊ฐ€ ๋“ค์–ด๊ฐˆ ์ˆ˜ ์žˆ๋„๋ก ์ด๋ฏธ์ง€ ์Šค์ผ€์ผ์„ ์กฐ์ •ํ•œ๋‹ค. ๋†’์ด๋ฅผ 150์œผ๋กœ ๋ณ€๊ฒฝํ•˜๋ฉด ํ™•์ธ ๊ฐ€๋Šฅ</div>

</body>
</html>