๋„ค์ด๋ฒ„ ๋ถ€์ŠคํŠธ์ฝ”์Šค/[๋ถ€์ŠคํŠธ์„œํฌํ„ฐ์ฆˆ3๊ธฐ]์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ์˜ ์‹œ์ž‘

[๋ถ€์ŠคํŠธ์ฝ”์Šค]์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ์˜ ์‹œ์ž‘(๋ฐ์ดํ„ฐํƒ€์ž…, ๋ณ€์ˆ˜์™€ ๋Œ€์ž…์—ฐ์‚ฐ์ž, ์›น๋ธŒ๋ผ์šฐ์ € ์ œ์–ด, CSS๊ธฐ์ดˆ, ์ œ์–ด ํƒœ๊ทธ ์„ ํƒ)

mmin.h 2021. 1. 11. 21:31

์•ˆ๋…•ํ•˜์„ธ์š” ๋ถ€์Šคํ„ฐ์ฝ”์Šค 3๊ธฐ ์„œํฌํ„ฐ์ฆˆ ํ—ˆ๋ธŒ์ž…๋‹ˆ๋‹ค. ๐ŸŒฟ

๋ถ€์Šคํ„ฐ์ฝ”์Šค๋ž€?

์ปค๋„ฅํŠธ์žฌ๋‹จ์€ ๋„ค์ด๋ฒ„๊ฐ€ ์„ค๋ฆฝํ•œ ๋น„์˜๋ฆฌ ๊ต์œก ์žฌ๋‹จ์ž…๋‹ˆ๋‹ค.
์†Œํ”„ํŠธ์›จ์–ด ๊ฐœ๋ฐœ์ž ์–‘์„ฑ ๊ต์œก ํ”„๋กœ๊ทธ๋žจ, ๋ถ€์ŠคํŠธ์ฝ”์Šค์™€ ํ•จ๊ป˜
๋‹น์‹ ์˜ ๊ฐœ๋ฐœ ์ปค๋ฆฌ์–ด๋ฅผ ์—…๊ทธ๋ ˆ์ด๋“œํ•˜์„ธ์š”!

 

์ œ ํฌ์ŠคํŒ…์€ ๊ฐ•์˜ ๋‚ด ์ƒ๊ฐํ•ด๋ณด๊ธฐ์™€ ์ˆ˜์—…์—์„œ ๋‹ค๋ฃจ๋Š” ์ฝ”๋“œ๋ฅผ ์ง์ ‘ ํฌ๋กฌํ™”๋ฉด์—์„œ ํ™•์ธ ํ•ด๋ณผ ์ˆ˜ ์žˆ๋„๋ก ์ง„ํ–‰ํ•ฉ๋‹ˆ๋‹ค. ๊ด€๋ จ๋œ ๊ฐœ๋…๊ณผ ๊ฐ•์˜๋Š” ํ•จ๊ป˜ ์˜ฌ๋ ค๋“œ๋ฆฌ๋Š” ๋งํฌ์—์„œ ํ™•์ธํ•ด๋ณด์‹ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. 

www.boostcourse.org/cs124/joinLectures/52258

 

์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ์˜ ์‹œ์ž‘

๋ถ€์ŠคํŠธ์ฝ”์Šค ๋ฌด๋ฃŒ ๊ฐ•์˜

www.boostcourse.org

 

var ๋‹น์ฒจ์ž์ˆ˜ = 2; 
var ๋Œ“๊ธ€์„ ํƒ์ž = '๋Œ“๊ธ€ ์ฃผ์†Œ';
function shuffle(a){
    for(let i = a.length; i; i--){
        let j = Math.floor(Math.random() * i);
        [a[i-1],a[j]] = [a[j],a[i-1]];
    }
}
var list =  []; 
document.querySelectorAll(๋Œ“๊ธ€์„ ํƒ์ž).forEach(function(e){
    list.push(e.innerText);
});
list = list.filter((v,i,a) => a.indexOF(v) ===i);
shuffle(list)
console.log(list.slice(0,๋‹น์ฒจ์ž์ˆ˜));

์ด ์ฝ”๋“œ๋Š” ์ €๋ฒˆ ์‹œ๊ฐ„ ์ฝ˜์†” ๊ฐ•์˜์—์„œ ์ž๋ฐ” ์Šคํฌ๋ฆฝํŠธ๋ฅผ ํ™œ์šฉํ•ด์„œ ํŽ˜์ด์Šค๋ถ ๋Œ“๊ธ€ ์ถ”์ฒจ ์ด๋ฒคํŠธ๋ฅผ ๋งŒ๋“  ์ฝ”๋“œ์˜€์Šต๋‹ˆ๋‹ค. ๋”ฐ๋กœ ์˜ˆ์ œ๋กœ ์˜ฌ๋ผ์˜ค์ง€ ์•Š์•„ ์ด๋ ‡๊ฒŒ ์ฝ”๋“œ๋กœ ์ž‘์„ฑํ•˜์—ฌ ์˜ฌ๋ ค๋“œ๋ฆฝ๋‹ˆ๋‹ค.

 

6. ๋ฐ์ดํ„ฐ ํƒ€์ž…(๋ฌธ์ž์—ด๊ณผ ์ˆซ์ž)

www.boostcourse.org/cs124/lecture/194588

 

์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ์˜ ์‹œ์ž‘

๋ถ€์ŠคํŠธ์ฝ”์Šค ๋ฌด๋ฃŒ ๊ฐ•์˜

www.boostcourse.org

์ž๋ฃŒํ˜•

์ˆซ์ž(number)

๋ฌธ์ž์—ด(String)

๋ฌธ์ž์—ด์ธ์ง€ ์ˆซ์ž์ธ์ง€์— ๋”ฐ๋ผ ์—ฐ์‚ฐ์˜ ๊ฒฐ๊ณผ๊ฐ€ ํฌ๊ฒŒ ๋‹ฌ๋ผ์งˆ ์ˆ˜ ์žˆ๋‹ค

'helloworld'.toUpperCase();
"HELLOWORLD"

'helloworld'.indexOf('o');
4

1+1
2
'1'+'1'
"11"

์ƒ๊ฐํ•ด๋ณด๊ธฐ

  1. 1+2๋ฅผ ๊ณ„์‚ฐํ–ˆ์„ ๋•Œ์™€ "1"+"2"๋ฅผ ๊ณ„์‚ฐํ–ˆ์„ ๋•Œ์˜ ๊ฒฐ๊ณผ๋Š” ๊ฐ๊ฐ ์–ด๋–ป๊ฒŒ ๋ ๊นŒ์š”? ์™œ ์ด๋Ÿฐ ์ฐจ์ด๊ฐ€ ๋ฐœ์ƒํ•˜๋Š” ๊ฒƒ์ผ๊นŒ์š”?

    → 1+ 2๋Š” ์ˆซ์ž์ด๊ธฐ ๋•Œ๋ฌธ์— 3์ด๋ผ๊ณ  ๊ณ„์‚ฐ ๋˜๋Š” ๊ฒƒ์ด๊ณ  '1'+'2' ๋Š” ๋ฌธ์ž์ด๊ธฐ ๋•Œ๋ฌธ์— '12'๋ผ๊ณ  ๊ณ„์‚ฐ๋˜๋Š” ๊ฒƒ์ด๋‹ค.

 

7. ๋ณ€์ˆ˜์™€ ๋Œ€์ž…์—ฐ์‚ฐ์ž

https://www.boostcourse.org/cs124/lecture/194589

 

์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ์˜ ์‹œ์ž‘

๋ถ€์ŠคํŠธ์ฝ”์Šค ๋ฌด๋ฃŒ ๊ฐ•์˜

www.boostcourse.org

x =1; 
y = 1; 
console.log(x+y);

var name = 'egoing';
var s = ' Lorem ipsum dolor sit amet consectetur, adipisicing elit. Dolor doloremque '+name+ ' perferendis '+name+' itaque temporibus';
console.log(s);

๋ณ€์ˆ˜์˜ ํšจ์šฉ์„ฑ์„ ์•Œ์•„๋ณผ ์ˆ˜ ์žˆ๋‹ค.

๋งŒ์•ฝ name ์ด 1์–ต๊ฐœ๊ฐ€ ๋“ค์–ด๊ฐ„๋‹ค๊ณ  ํ• ๋•Œ ๋‹ค ๋ฐ”๊พธ๊ธฐ์—๋Š” ์–ด๋ ต๊ธฐ ๋–„๋ฌธ์— ๋ณ€์ˆ˜๋งŒ ๋ฐ”๊ฟ”์ฃผ๋ฉด ๋ชจ๋“  name์„ ๋ฐ”๊ฟ”์ค„ ์ˆ˜ ์žˆ๋Š” ๊ฒƒ์ด๋‹ค.

์ƒ๊ฐํ•ด๋ณด๊ธฐ

  1. ๊ฐ•์˜์—์„œ ์–ธ๊ธ‰๋œ ๊ฒƒ ์™ธ์— ๋ณ€์ˆ˜๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ ์ข‹์€ ์ ์—๋Š” ์–ด๋–ค ๊ฒƒ๋“ค์ด ์žˆ์„๊นŒ์š”?

    → ๊ฐ’์„ ์ž„์‹œ๋กœ ์ €์žฅํ•ด๋‘๊ณ  ์ˆซ์ž๋ฅผ ๋ฐ”๊พผ๋‹ค๊ฑฐ๋‚˜, ๊ณ„์† ์“ฐ์ด๋Š” ๊ฐ’์„ ์ €์žฅํ•ด๋‘๋ฉด ์œ ์šฉํ•˜๋‹ค.

 

8. ์›น๋ธŒ๋ผ์šฐ์ € ์ œ์–ด

https://www.boostcourse.org/cs124/lecture/194590/

 

์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ์˜ ์‹œ์ž‘

๋ถ€์ŠคํŠธ์ฝ”์Šค ๋ฌด๋ฃŒ ๊ฐ•์˜

www.boostcourse.org

์‹œ์ž‘ํ•˜๊ธฐ ์ „์— ๊ฐ„๋‹จํ•˜๊ฒŒ ๋ช‡ ๊ฐ€์ง€๋ฅผ ์งš๊ณ  ๋„˜์–ด๊ฐ€ ๋ด…์‹œ๋‹ค. ๋จผ์ € ์ด ์›น์‚ฌ์ดํŠธ์˜ ์ƒ‰๊น”์ด ์ด๋ ‡๊ฒŒ ๋ฐ”๋€Œ๊ธฐ ์œ„ํ•ด์„œ๋Š” <body> ํƒœ๊ทธ์˜ ์†์„ฑ์ด ๋ฐ”๋€Œ์–ด์•ผ ํ•œ๋‹ค๋Š” ์‚ฌ์‹ค์ž…๋‹ˆ๋‹ค.

 

<body>
<body style="background-color: black; color: white;">

์ž ์ด๋ ‡๊ฒŒ ๋ณด์‹œ๋ฉด ๋„ค์ด๋ฒ„ ๋ถ€์ŠคํŠธ์ฝ”์Šค๋Š” aside์™€ body๋กœ ๋‚˜๋‰˜์–ด ๋ ˆ์ด์•„์›ƒ์ด ๋งŒ๋“ค์–ด์ ธ์žˆ๋‹ค๋Š” ๊ฒƒ์„ ์•Œ ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค. black ์€ ๊ธ€์”จ๊ฐ€ ์•ˆ๋ณด์—ฌ์„œ gray๋กœ ํ•œ๋ฒˆ ๋ฐ”๊พธ์–ด ๋ณด์•˜์Šต๋‹ˆ๋‹ค.

์—ฌ๋Ÿฌ๋ถ„๋“ค๋„ ํฌ๋กฌ์˜ ๊ฒ€์‚ฌ์ฐฝ์„ ์ผœ์„œ body์˜ ๋ฐฐ๊ฒฝ ์ƒ‰์„ ์ˆ˜์ •ํ•ด๋ณด์‹œ๊ธฐ ๋ฐ”๋ž๋‹ˆ๋‹ค.

 

์ƒ๊ฐํ•ด๋ณด๊ธฐ

  1. ์ง์ ‘ body ํƒœ๊ทธ์˜ style ์†์„ฑ์„ ๋ฐ”๊พธ์–ด ๋ฐฐ๊ฒฝ ์ƒ‰์€ ํŒŒ๋ž€์ƒ‰, ๊ธ€์ž ์ƒ‰์€ ํšŒ์ƒ‰์œผ๋กœ ๋งŒ๋“ค์–ด ๋ด…์‹œ๋‹ค.

๋ถ€์ŠคํŠธ์ฝ”์Šค ์‚ฌ์ดํŠธ์˜ ๋ฐฐ๊ฒฝ์„ ๋ฐ”๊พธ์–ด๋ณด์•˜์Šต๋‹ˆ๋‹ค. blue๋Š” ๊ธ€์”จ๊ฐ€ ๋„ˆ๋ฌด ์•ˆ๋ณด์—ฌ์„œ ์กฐ๊ธˆ ์—ฐํ•œ ๋ธ”๋ฃจ๋กœ ๋ฐ”๊พธ์–ด ๋ณด์•˜์Šต๋‹ˆ๋‹ค.

 

9. CSS๊ธฐ์ดˆ(style ์†์„ฑ)

https://www.boostcourse.org/cs124/lecture/194591

 

์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ์˜ ์‹œ์ž‘

๋ถ€์ŠคํŠธ์ฝ”์Šค ๋ฌด๋ฃŒ ๊ฐ•์˜

www.boostcourse.org

์ด ๋•Œ ์ด color: blue๋ผ๋Š” ์ฝ”๋“œ๊ฐ€ ๋ฐ”๋กœ CSS์ž…๋‹ˆ๋‹ค.

CSS๋ฅผ ์ด์šฉํ•˜๋ฉด ๋‹ค์–‘ํ•œ ์ข…๋ฅ˜์˜ ๋””์ž์ธ ์š”์†Œ๋ฅผ ๋ฐ”๊ฟ€ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด color ๋Œ€์‹  background-color์„ ์“ฐ๋ฉด ๋ฐฐ๊ฒฝ ์ƒ‰์ด ๋ฐ”๋€Œ๋Š” ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ์„ ๊ฒ๋‹ˆ๋‹ค.

์ด๋Ÿฌํ•œ ์š”์†Œ๋“ค์„ ์•Œ์•„๋ณด๊ณ  ์‹ถ๋‹ค๋ฉด CSS property + "์›ํ•˜๋Š” ๋””์ž์ธ ์š”์†Œ" ๋กœ ๊ฒ€์ƒ‰ํ•ด๋ณด์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด "CSS property background color"๋กœ ๊ฒ€์ƒ‰ํ•˜๋ฉด, ๋ฐฉ๊ธˆ ๋ฐฐ์šด background-color๋ผ๋Š” CSS ์†์„ฑ์— ๋Œ€ํ•ด์„œ ์•Œ์•„๋ณด์‹ค ์ˆ˜ ์žˆ์„ ๊ฒ๋‹ˆ๋‹ค.

<h1>Javascript<h1>
<h1 style="color: blue">Javascript<h1>

์ด ์™ธ์—๋„ ๋‹ค์–‘ํ•œ ๋ฐฉ๋ฒ•์œผ๋กœ css๋ฅผ ์ ์šฉ์‹œํ‚ฌ ์ˆ˜ ์žˆ๋Š”๋ฐ ๊ทธ๊ฒƒ์€ ์›น UI ์ฝ”์Šค๋ฅผ ๋ณด์‹œ๋ฉด ๋”์šฑ ์ดํ•ด๊ฐ€ ์‰ฌ์šฐ ์‹ค ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

์ƒ๊ฐํ•ด๋ณด๊ธฐ

  1. ๊ฐ•์˜์—์„œ ๋ฐฐ์šด color์™€ background-color์„ ์ด์šฉํ•ด์„œ ๋ฐฐ๊ฒฝ์ด ์ดˆ๋ก์ƒ‰์ด๊ณ  ๊ธ€์ž๊ฐ€ ํฐ์ƒ‰์ธ ๋ฌธ๋‹จ์„ ๋งŒ๋“ค์–ด ๋ด…์‹œ๋‹ค.

  2. CSS๋ฅผ ์ด์šฉํ•ด์„œ ๊ธ€์ž ํฌ๊ธฐ๋ฅผ ํ‚ค์›Œ๋ด…์‹œ๋‹ค. (ํžŒํŠธ : CSS property font size ๋ผ๊ณ  ๊ฒ€์ƒ‰ํ•ด ๋ณด์„ธ์š”!)

<h1 style="font-size:50px;">boostcouse javaScript</h1>
<h1 style="color:white; background-color:green">boostcouse javaScript</h1>

10. CSS๊ธฐ์ดˆ(style ํƒœ๊ทธ)

https://www.boostcourse.org/cs124/lecture/194592

 

์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ์˜ ์‹œ์ž‘

๋ถ€์ŠคํŠธ์ฝ”์Šค ๋ฌด๋ฃŒ ๊ฐ•์˜

www.boostcourse.org

์šฐ๋ฆฌ๊ฐ€ CSS๋ฅผ ์ด์šฉํ•ด์„œ ๋ฌธ๋‹จ์˜ ํŠน์ • ๋ถ€๋ถ„์—๋งŒ ์Šคํƒ€์ผ์„ ์ฃผ์–ด์„œ ๊ฐ•์กฐ๋ฅผ ํ•˜๊ณ  ์‹ถ๋‹ค๊ณ  ํ•ด ๋ด…์‹œ๋‹ค. ์ด ๋•Œ ์ด ๋ถ€๋ถ„์„ ๊ฐ์‹ธ์ค„ ์ˆ˜ ์žˆ๋Š” HTML ํƒœ๊ทธ๊ฐ€ ํ•„์š”ํ•˜๊ฒ ์ฃ .

์ด๋ฅผ ์œ„ํ•ด์„œ ์šฐ๋ฆฌ๋Š” div์™€ span์ด๋ผ๋Š” ํƒœ๊ทธ๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.


๋‘˜ ๋ชจ๋‘ ์–ด๋– ํ•œ ํŠน์ •ํ•œ ๊ธฐ๋Šฅ์ด ์žˆ๋Š” ํƒœ๊ทธ๊ฐ€ ์•„๋‹ˆ๊ณ , CSS๋‚˜ Javascript ์ฝ”๋“œ๋ฅผ ์‚ฝ์ž…ํ•˜๊ธฐ ์œ„ํ•ด์„œ ์กด์žฌํ•˜๋Š” ํƒœ๊ทธ์ž…๋‹ˆ๋‹ค. div ํƒœ๊ทธ๋Š” ํ™”๋ฉด ์ „์ฒด๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์ค„๋ฐ”๊ฟˆ์ด ๋˜๊ณ , span์€ ์ค„๋ฐ”๊ฟˆ์ด ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

์ด์ œ ์ด๋Ÿฌํ•œ div์™€ span ํƒœ๊ทธ ์•ˆ์— style ์†์„ฑ์„ ๋ถ€์—ฌํ•˜๋ฉด ์ด ํƒœ๊ทธ๋กœ ๊ฐ์‹ธ์ง„ ๋ถ€๋ถ„์—๋งŒ ๋””์ž์ธ์ด ์ ์šฉ๋˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

 

ํ•˜์ง€๋งŒ ์ด๋ ‡๊ฒŒ ๋ชจ๋“  ๋ถ€๋ถ„์„ div๋‚˜ span ํƒœ๊ทธ๋กœ ๊ฐ์‹ธ๋ ค๊ณ  ํ•œ๋‹ค๋ฉด ์ด๋ฅผ ์“ฐ๊ธฐ๋„ ํž˜๋“ค๊ณ , ์ˆ˜์ •ํ•˜๊ธฐ๋Š” ๋”์šฑ ํž˜๋“ค ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์ด๋ฅผ ์œ„ํ•ด์„œ CSS์—๋Š” ์„ ํƒ์ž๋ผ๋Š” ๊ธฐ๋Šฅ์ด ์กด์žฌํ•ฉ๋‹ˆ๋‹ค.

 

Class

์ด๋ฅผ ์œ„ํ•ด์„œ๋Š” <head> ํƒœ๊ทธ ์•ˆ์— <style>์ด๋ผ๋Š” ์ƒˆ๋กœ์šด ํƒœ๊ทธ๋ฅผ ๋งŒ๋“ค์–ด ์ค๋‹ˆ๋‹ค. ์ด style ํƒœ๊ทธ ์•ˆ์—๋Š” CSS ์ฝ”๋“œ๊ฐ€ ๋“ค์–ด๊ฐ€๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  js๋ผ๋Š” class๋ฅผ ์ƒ์„ฑํ•ด ๋ด…์‹œ๋‹ค. ์•„๋ž˜ ์ฝ”๋“œ์™€ ๊ฐ™์ด ๋ง์ด์ฃ 

<head>
  <style>
    .js {
        font-weight: bold;
    }
  </style>
</head>

์ด ๋•Œ js ์•ž์— ์ฐํ˜€์žˆ๋Š” ์ ์€ js๋ผ๋Š” ์ด๋ฆ„์ด class ์ด๋ฆ„์ด๋ผ๋Š” ๊ฒƒ์„ ๋‚˜ํƒ€๋ƒ…๋‹ˆ๋‹ค. ์ด๋ ‡๊ฒŒ class๋ฅผ ๋งŒ๋“ค์—ˆ์œผ๋‹ˆ, ์ด๋ฅผ HTML ์ฝ”๋“œ์˜ ๊ณณ๊ณณ์— ์ ์šฉ์‹œํ‚ค๋ฉด ๋ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด ์–ด๋–ค ๋ฌธ์žฅ์—์„œ Javascript๋ผ๋Š” ๋‹จ์–ด์—๋งŒ ์ด class๋ฅผ ์ ์šฉ์‹œ์ผœ์„œ ๋ณผ๋“œ์ฒด๋กœ ๋งŒ๋“ค๊ณ  ์‹ถ๋‹ค๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์“ฐ๋ฉด ๋ฉ๋‹ˆ๋‹ค.

<span class="js">Javascript</span> is wonderful!

์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ์ด์ œ js๋ผ๋Š” class๋ฅผ ๊ฐ€์ง„ ๋ชจ๋“  ํƒœ๊ทธ๋ฅผ ํ•œ ๋ฒˆ์— ๋ฐ”๊ฟ€ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. style ํƒœ๊ทธ ์•ˆ์— ์žˆ๋Š” .js๋งŒ ์ˆ˜์ •ํ•˜๋ฉด ๋ชจ๋“  ๋ถ€๋ถ„์„ ํ•œ ๋ฒˆ์— ๋ฐ”๊ฟ€ ์ˆ˜ ์žˆ๋Š” ๊ฒƒ์ด์ฃ .

 

์ƒ๊ฐํ•ด๋ณด๊ธฐ

  1. js class์— ๋‹ค์–‘ํ•œ ์Šคํƒ€์ผ์„ ์ถ”๊ฐ€ํ•ด์„œ Javascript๋ผ๋Š” ๊ธ€์ž๋ฅผ ๊พธ๋ฉฐ๋ด…์‹œ๋‹ค.

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .js {
            background-color: gray;
            color: white;
            font-size: 50px;
        }
    </style>
</head>

<body>
    <p class='js'>boostcousrse</p>
</body>

</html>

 

11. CSS๊ธฐ์ดˆ(์„ ํƒ์ž)

https://www.boostcourse.org/cs124/lecture/194593

 

์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ์˜ ์‹œ์ž‘

๋ถ€์ŠคํŠธ์ฝ”์Šค ๋ฌด๋ฃŒ ๊ฐ•์˜

www.boostcourse.org

์„ ํƒ์ž

์„ ํƒ์ž์—๋Š” ์ €๋ฒˆ ๊ฐ•์˜์—์„œ ๋ฐฐ์šด class ์™ธ์—๋„ id๊ฐ€ ์กด์žฌํ•ฉ๋‹ˆ๋‹ค. ์ €๋ฒˆ ๊ฐ•์˜์—์„œ class์— ๋Œ€ํ•œ ์Šคํƒ€์ผ์„ ์ง€์ •ํ•  ๋•Œ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์ฝ”๋“œ๋ฅผ <head> ํƒœ๊ทธ ์•ˆ์— ๋„ฃ์–ด์ฃผ์—ˆ์ฃ .

<style>
  .js {
    color: red;
  }
</style>

id๋Š” class์™€๋Š” ๋‹ฌ๋ฆฌ .๋Œ€์‹  #์„ ๋ถ™์—ฌ์•ผ ํ•œ๋‹ค๋Š” ์ฐจ์ด์ ์ด ์žˆ์Šต๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด์„œ first๋ผ๋Š” id๋ฅผ ๋งŒ๋“ค ๋•Œ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๋‚˜ํƒ€๋‚ด๋Š” ๊ฒƒ์ด์ฃ .

<style>
  #first {
    color: green;
  }
</style>

๊ทธ๋ ‡๋‹ค๋ฉด ๋งŒ์•ฝ class์™€ id๊ฐ€ ๋ชจ๋‘ ์ง€์ •๋˜์–ด ์žˆ๋Š” ํƒœ๊ทธ์—์„œ๋Š”, ๋‘˜ ์ค‘์— ์–ด๋–ค ๋””์ž์ธ์„ ๋”ฐ๋ผ๊ฐ€๊ฒŒ ๋ ๊นŒ์š”? ์ด๋ฅผ ์œ„ํ•ด์„œ class์™€ id์˜ ์ฐจ์ด์ ์„ ์•Œ์•„๋ด…์‹œ๋‹ค.

 

class๋ผ๋Š” ๋‹จ์–ด๋Š” ๊ทธ๋ฃน์„ ์˜๋ฏธํ•˜๊ณ , id๋Š” ํŠน์ •ํ•œ ๊ฒƒ์„ ์‹๋ณ„ํ•œ๋‹ค๋Š” ์˜๋ฏธ์ž…๋‹ˆ๋‹ค. class ์„ ํƒ์ž๋Š” ๊ฐ™์€ ์Šคํƒ€์ผ์ด ์ง€์ •๋  ๊ทธ๋ฃน์„ ์˜๋ฏธํ•˜๋Š” ๊ฒƒ์ด๊ณ , id๋Š” ํŠน์ •ํ•œ ํƒœ๊ทธ์—๋งŒ ์ง€์ •ํ•˜๊ณ  ์‹ถ์€ ์Šคํƒ€์ผ์„ ๋‚˜ํƒ€๋‚ด๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. ๊ทธ๋ž˜์„œ class๋Š” ์ค‘๋ณต๋  ์ˆ˜ ์žˆ์ง€๋งŒ, id๋Š” ํ•œ ํŽ˜์ด์ง€์—์„œ๋Š” ๋”ฑ ํ•œ๋ฒˆ๋งŒ ์“ฐ์ด๊ฒŒ ๋˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.

 

์ฆ‰, class ์„ ํƒ์ž๊ฐ€ id ์„ ํƒ์ž์— ๋น„ํ•ด์„œ ๋” ํฌ๊ด„์ ์ž…๋‹ˆ๋‹ค. class ์„ ํƒ์ž๋ฅผ ์ด์šฉํ•˜๋ฉด ๊ด‘๋ฒ”์œ„ํ•œ ํšจ๊ณผ๋ฅผ ์ค„ ์ˆ˜ ์žˆ๊ณ , id ์„ ํƒ์ž๋ฅผ ์ด์šฉํ•˜๋ฉด ์˜ˆ์™ธ์ ์œผ๋กœ ๋””์ž์ธ์„ ๋ฐ”๊ฟ€ ์ˆ˜ ์žˆ๋Š” ๊ฒƒ์ด์ฃ . ๊ทธ๋ ‡๊ธฐ ๋•Œ๋ฌธ์— class ์œ„์— id๋ฅผ ์–น์–ด์„œ ๊ตฌํ˜„ํ•˜๋Š” ๊ฒƒ์ด ํšจ์œจ์ ์ž…๋‹ˆ๋‹ค.

 

์„ ํƒ์ž์˜ ์šฐ์„ ์ˆœ์œ„

๋งˆ์ง€๋ง‰์œผ๋กœ id ์„ ํƒ์ž์™€ class ์„ ํƒ์ž ์™ธ์— ์Šคํƒ€์ผ์„ ๋‚˜ํƒ€๋‚ด๋Š” ํ•œ ๊ฐ€์ง€ ๋ฐฉ๋ฒ•์„ ๋” ์•Œ์•„๋ด…์‹œ๋‹ค. ๋งŒ์•ฝ ์•ž์— .๊ณผ # ๋ชจ๋‘ ์ง€์ •ํ•˜์ง€ ์•Š์œผ๋ฉด ๊ทธ๊ฒƒ์€ ํƒœ๊ทธ ์ด๋ฆ„์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค. ์ฆ‰ ์•„๋ž˜์™€ ๊ฐ™์€ ์ฝ”๋“œ๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ์ด ํŽ˜์ด์ง€์—์„œ span์ด๋ผ๋Š” ์ด๋ฆ„์˜ ํƒœ๊ทธ๋Š” ๋ชจ๋‘ ๋””์ž์ธ์ด ๋ฐ”๋€Œ๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.

 

id > class > ํƒœ๊ทธ ์ˆœ์„œ๋กœ ์šฐ์„ ์ˆœ์œ„๋ฅผ ๊ฐ€์ง€๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

 

์ƒ๊ฐํ•ด๋ณด๊ธฐ

1) ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์ฝ”๋“œ๊ฐ€ ์žˆ์„ ๋•Œ, Javascript๋ผ๋Š” ๊ธ€์ž์—๋Š” ์–ด๋–ค ์ƒ‰๊น”์ด ๋‚˜ํƒ€๋‚ ๊นŒ์š”? ๊ธ€์ž์˜ ํฌ๊ธฐ๋Š” ์–ผ๋งˆ๊ฐ€ ๋ ๊นŒ์š”?

<style>
  span {
    color: blue;
  }
  .hello {
    font-size: 12px;
    color: red;
  }
  #bye {
    font-size: 13px;
  }
</style>
<span id="bye" class="hello">Javascript</span>

๊ฒฐ๊ณผ๋ฅผ ๋ณด์‹œ๋ฉด ํด๋ž˜์Šค์˜ css ์ฝ”๋“œ์ƒ‰์ƒ๊ณผ id์˜ ํฐํŠธ๊ฐ€ ์„œ์ •๋œ ๊ฒƒ์„ ์•Œ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

id > class > ํƒœ๊ทธ ์ˆœ์„œ๋กœ ์šฐ์„ ์ˆœ์œ„๋ฅผ ๊ฐ€์ง€๊ฒŒ ๋œ๋‹ค๊ณ  ์ด์•ผ๊ธฐ ๋“œ๋ ธ์Šต๋‹ˆ๋‹ค.

๊ทธ๋ ‡๊ธฐ ๋•Œ๋ฌธ์— 13px ์ด ์ ์šฉ๋˜๊ณ  class ์˜ color ์˜ ๊ฐ’์ด ์ ์šฉ๋˜๊ณ  12px์€ id๊ฐ€ ์šฐ์„ ์ˆœ์œ„๊ฐ€ ๋†’๊ธฐ ๋•Œ๋ฌธ์— ์ ์šฉ๋˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค.

span ํƒœ๊ทธ๋ฅผ ๊ฐ€๋ฆฌํ‚ค๋Š” css ์ฝ”๋“œ๋„ hello ํด๋ž˜์Šค๊ฐ€ ์šฐ์„ ์ˆœ์œ„๊ฐ€ ๋” ๋†’๊ธฐ ๋•Œ๋ฌธ์— blue๊ฐ€ ์ ์šฉ๋˜์ง€ ์•Š์•˜์Œ์„ ์•Œ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

12. ์ œ์–ดํ•  ํƒœ๊ทธ ์„ ํƒํ•˜๊ธฐ

https://www.boostcourse.org/cs124/lecture/194594

 

์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ์˜ ์‹œ์ž‘

๋ถ€์ŠคํŠธ์ฝ”์Šค ๋ฌด๋ฃŒ ๊ฐ•์˜

www.boostcourse.org

์˜ค๋Š˜์€ ์˜ˆ์ œ๋ฅผ ํ•œ๋ฒˆ ๊ฐ™์ด ์ฐพ์•„๋ณด๋Š” ์‹œ๊ฐ„์ž…๋‹ˆ๋‹ค.

javascript select by css selector์˜ ๊ด€๋ จ์€ ์—ฌ๊ธฐ์„œ ์ฐพ์•„๋ณด์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค.

https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector

 

Document.querySelector() - Web APIs | MDN

The Document method querySelector() returns the first Element within the document that matches the specified selector, or group of selectors. If no matches are found, null is returned. Note: The matching is done using depth-first pre-order traversal of the

developer.mozilla.org

javascript style background color

https://www.w3schools.com/jsref/prop_style_backgroundcolor.asp

 

HTML DOM Style backgroundColor Property

Style backgroundColor Property โฎ Style Object Example Set a background color for a document: document.body.style.backgroundColor = "red"; Try it Yourself » More "Try it Yourself" examples below. Definition and Usage The backgroundColor property sets or

www.w3schools.com

์ œ๊ฐ€ ๋งŒ๋“ค์–ด ๋ณธ ์˜ˆ์ œ ์ฝ”๋“œ๋Š” ์•„๋ž˜์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค. night ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด ๋‚˜์ดํŠธ ๋ชจ๋“œ๋กœ ๋ฐ”๋€Œ์–ด ๋ฐฐ๊ฒฝ์ƒ‰์€ ๊ฒ€์ •, ๊ธ€์ž์ƒ‰์€ ํฐ์ƒ‰์œผ๋กœ ๋ฐ”๋€๋‹ˆ๋‹ค. 

๊ทธ๋ฆฌ๊ณ  day ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด ๋‹ค์‹œ ๊ธฐ์กด์˜ ๋ฐฐ๊ฒฝ์ƒ‰๊ณผ ๊ธ€์ž์ƒ‰์ธ ํฐ์ƒ‰๊ณผ ๊ฒ€์ •์ƒ‰์œผ๋กœ ๋ฐ”๋€Œ๋Š” ํ™”๋ฉด์ž…๋‹ˆ๋‹ค. 

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>WEB1 - javaScript</title>
</head>

<body style="">
    <h1><a href="index.html">WEB</a></h1>
    <input type="button" value="night" onclick="
        document.querySelector('body').style.backgroundColor = 'black';
        document.querySelector('body').style.color = 'white';

    ">
    <input type="button" value="day" onclick="
        document.querySelector('body').style.backgroundColor = 'white';
        document.querySelector('body').style.color = 'black';
        
    ">

    <ol>
        <li><a href="1.html">HTML</a></li>
        <li><a href="2.html">CSS</a></li>
        <li><a href="3.html">JAVASCRIPT</a></li>
    </ol>
    <h2>JavaScript</h2>
    <p>
        Lorem ipsum dolor sit amet consectetur adipisicing elit. Sapiente officia incidunt quas reprehenderit alias
        eveniet necessitatibus eligendi harum obcaecati temporibus, odit, dolor nulla adipisci tempore illum suscipit
        quod voluptatibus debitis quam atque nemo accusantium voluptatum voluptates voluptas. Laudantium labore,
        praesentium architecto perspiciatis enim totam! Magni fugit corporis iste ratione dolorem temporibus. Magni
        perferendis aspernatur mollitia! Eaque dolorem, exercitationem corrupti amet aliquid quis ab eligendi. Nam odio
        maxime quae explicabo repellat velit error fuga dolores quo quia. Quidem beatae iusto dolore eos, consequatur
        fuga magnam! Sed esse asperiores dolor et adipisci corrupti eveniet tempore deleniti rerum possimus natus,
        reiciendis accusantium ut reprehenderit! Animi quaerat ratione, facere saepe iusto eos, obcaecati, provident
        ius doloribus nam! Modi, hic! Est vel ipsam laborum placeat! Non nulla dolorum autem corrupti.
    </p>
</body>

</html>

 

 

 

๋„ค์ด๋ฒ„ ์ปค๋„ฅํŠธ ๋ถ€์Šคํ„ฐ์ฝ”์Šค 3๊ธฐ ์„œํฌํ„ฐ์ฆˆ ํ—ˆ๋ธŒ๐ŸŒฟ

www.boostcourse.org/

github.com/hhhminme

 

hhhminme - Overview

๊พธ์ค€ํžˆ ๊ณต๋ถ€์ค‘์ธ ์ดˆ๋ณด ๊ฐœ๋ฐœ์ž์ง€๋ง์ƒ hub@kakao.com. hhhminme has 13 repositories available. Follow their code on GitHub.

github.com

 

๋‹ค ํ•จ๊ป˜ ๋ฐฐ์šฐ๊ณ  ์„ฑ์žฅํ•˜๋Š” ๋ถ€์ŠคํŠธ์ฝ”์Šค

๋ถ€์ŠคํŠธ์ฝ”์Šค(boostcourse)๋Š” ๋ชจ๋‘ ํ•จ๊ป˜ ๋ฐฐ์šฐ๊ณ  ์„ฑ์žฅํ•˜๋Š” ๋น„์˜๋ฆฌ SW ์˜จ๋ผ์ธ ํ”Œ๋žซํผ์ž…๋‹ˆ๋‹ค.

www.boostcourse.org