๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๐Ÿ’ป Extracurricular/๋ฉ‹์Ÿ์ด์‚ฌ์ž์ฒ˜๋Ÿผ11๊ธฐ

[2์ฃผ์ฐจ] HTML && CSS && JavaScript

“ ์›น์„ ์ด๋ฃจ๊ณ  ์žˆ๋Š” ๊ตฌ์„ฑ์š”์†Œ 3๊ฐ€์ง€๋ฅผ ๊ณต๋ถ€ํ•ด๋ด…์‹œ๋‹ค ! ”

๐Ÿ’ก ์œ ์šฉํ•œ ํŽธ์ง‘๊ธฐ vscode๋ฅผ ์‚ฌ์šฉํ•ด ๋ณผ๊นŒ์š”? ์œ ์šฉํ•œ ํ™•์žฅํŒฉ๋“ค์ด ๋งŽ์ด ์žˆ์–ด์š” !

๐Ÿ’ก ์›น ํด๋ผ์ด์–ธํŠธ๋Š” chrome์„ ๊ถŒ์žฅํ•ฉ๋‹ˆ๋‹ค.

โš ๏ธ ์ œ์ถœํ•˜๋Š” ๋ชจ๋“  html ํŒŒ์ผ๋“ค์€ HTML validator ๋ฅผ ํ†ต๊ณผํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.


์ฐธ๊ณ 

HTML ์ˆ˜์—…

 

HTML ์ˆ˜์—… - ์ƒํ™œ์ฝ”๋”ฉ

์ˆ˜์—…์˜ ๋ชฉ์  ๋ณธ ์ˆ˜์—…์€ HTML์— ๋Œ€ํ•œ ์‹ฌํ™”๋œ ๋‚ด์šฉ์„ ๋‹ค๋ฃน๋‹ˆ๋‹ค. HTML์˜ ๊ธฐ๋ณธ๋ฌธ๋ฒ•๊ณผ HTML์˜ ์ฃผ์š”ํ•œ ํƒœ๊ทธ๋“ค์— ๋Œ€ํ•œ ์ˆ˜์—…์„ ๋‹ด๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.  ์„ ํ–‰ํ•™์Šต ๋ณธ ์ˆ˜์—…์„ ํšจ๊ณผ์ ์œผ๋กœ ์ˆ˜ํ–‰ํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ์›น์• ํ”Œ๋ฆฌ

opentutorials.org

CSS Reference

 

CSS Reference

W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.

www.w3schools.com

JavaScript Tutorial

 

JavaScript Tutorial

W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.

www.w3schools.com

 


์ถ”์ฒœ ๊ฐ•์˜

HTML ์ˆ˜์—… - ์ƒํ™œ์ฝ”๋”ฉ

 

HTML ์ˆ˜์—… - ์ƒํ™œ์ฝ”๋”ฉ

์ˆ˜์—…์˜ ๋ชฉ์  ๋ณธ ์ˆ˜์—…์€ HTML์— ๋Œ€ํ•œ ์‹ฌํ™”๋œ ๋‚ด์šฉ์„ ๋‹ค๋ฃน๋‹ˆ๋‹ค. HTML์˜ ๊ธฐ๋ณธ๋ฌธ๋ฒ•๊ณผ HTML์˜ ์ฃผ์š”ํ•œ ํƒœ๊ทธ๋“ค์— ๋Œ€ํ•œ ์ˆ˜์—…์„ ๋‹ด๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.  ์„ ํ–‰ํ•™์Šต ๋ณธ ์ˆ˜์—…์„ ํšจ๊ณผ์ ์œผ๋กœ ์ˆ˜ํ–‰ํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ์›น์• ํ”Œ๋ฆฌ

opentutorials.org

CSS ์ˆ˜์—… - ์ƒํ™œ์ฝ”๋”ฉ

 

CSS ์ˆ˜์—… - ์ƒํ™œ์ฝ”๋”ฉ

CSS๋Š” HTML์„ ์•„๋ฆ„๋‹ต๊ฒŒ ๊พธ๋ฉฐ์ฃผ๋Š” ๋””์ž์ด๋„ˆ์˜ ์–ธ์–ด์ž…๋‹ˆ๋‹ค. ํ™”๊ฐ€๊ฐ€ ๋ถ“์„ ๋งŒ๋“œ๋Š” ๋ฒ•์„ ์•Œ ํ•„์š”๋Š” ์—†์ง€๋งŒ, ๋ถ“์„ ๋งŒ๋“œ๋Š” ์‚ฌ๋žŒ๋ณด๋‹ค ๋ถ“ ์งˆ์€ ํ›จ์”ฌ ์ž˜ํ•ด์•ผ ํ•  ๊ฒƒ์ž…๋‹ˆ๋‹ค. ๋ถ“ ์งˆํ•˜๋Š” ๋ฒ•์„ ๋ชจ๋ฅธ๋‹ค๋ฉด ํ‘œํ˜„ํ•˜

opentutorials.org

์›น๋ธŒ๋ผ์šฐ์ € ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ - ์ƒํ™œ์ฝ”๋”ฉ

 

์›น๋ธŒ๋ผ์šฐ์ € ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ - ์ƒํ™œ์ฝ”๋”ฉ

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

opentutorials.org


๊ณผ์ œ

ex00

์ œ์ถœ ๋””๋ ‰ํ† ๋ฆฌ : ex00/

์ œ์ถœ ํŒŒ์ผ : MightyDev.html

์•„๋ž˜ ํ™”๋ฉด๊ณผ ๋™์ผํ•œ ๊ฒฐ๊ณผ๊ฐ€ ๋‚˜์˜ค๋„๋ก html ํŒŒ์ผ์„ ๋งŒ๋“ค์–ด์„œ ์ œ์ถœํ•˜์„ธ์š”.

๊ฒฐ๊ณผ)

โš ๏ธ ํ™”๋ฉด์— ์ฃผ์†Œ์ฐฝ์€ ์‹ ๊ฒฝ์“ฐ์ง€ ๋งˆ์„ธ์š”!

 

 

๐Ÿ’ก ํ•„์š”ํ•œ ๋ฌธ๋ฒ•

html

โžก๏ธ ์›น ํŽ˜์ด์ง€์˜ ์ด๋ฆ„ ์„ค์ •

<html>
<head>
	<title>์„ค์ •ํ•˜๊ณ  ์‹ถ์€ ์ด๋ฆ„</title>
</head>
<body>
	...
</body>
</html>

 

โžก๏ธ <h#> ํƒœ๊ทธ

<h1><h2><h3><h4><h5><h6> ํƒœ๊ทธ
์ด ํƒœ๊ทธ๋“ค์€ ์„น์…˜, ๋ฌธ๋‹จ์˜ ์ œ๋ชฉ์„ ๋‚˜ํƒ€๋‚ด๋ฉฐ ์ˆซ์ž๊ฐ€ ์ž‘์„์ˆ˜๋ก ๊ธ€์ž์˜ ํฌ๊ธฐ๊ฐ€ ์ปค์ง‘๋‹ˆ๋‹ค.

<html>
<body>
	<h2>html์€ ์ฒ˜์Œ์ด์ง€?</h2>
	<h3>1๋ฒˆ</h3>
	<p>
		์ €๋„ ์›น ๊ฐœ๋ฐœ์ด ์ฒ˜์Œ์ž…๋‹ˆ๋‹ค..
	</p>
	

	<h3>2๋ฒˆ</h3>
	<p>
		๋ฉ‹์Ÿ์ด์‚ฌ์ž์ฒ˜๋Ÿผ
	</p>

	<h5>์•„๊ธฐ ์‚ฌ์ž๊ฐ€ ๋˜๋ ค๋ฉด...</h5>
</body>
</html>

 

๊ฒฐ๊ณผ


html์€ ์ฒ˜์Œ์ด์ง€?

1๋ฒˆ

์ €๋„ ์›น ๊ฐœ๋ฐœ์ด ์ฒ˜์Œ์ž…๋‹ˆ๋‹ค..

2๋ฒˆ

๋ฉ‹์Ÿ์ด์‚ฌ์ž์ฒ˜๋Ÿผ

์•„๊ธฐ ์‚ฌ์ž๊ฐ€ ๋˜๋ ค๋ฉด...

 

โžก๏ธ <label>

  • label์€ ํผ์˜ ์–‘์‹์— ์ด๋ฆ„ ๋ถ™์ด๋Š” ํƒœ๊ทธ
  • ์ฃผ์š” ์†์„ฑ: for (label์˜ for์˜ ๊ฐ’๊ณผ ์–‘์‹์˜ id์˜ ๊ฐ’์ด ๊ฐ™์œผ๋ฉด ์—ฐ๊ฒฐ)
  • label์„ ํด๋ฆญํ•˜๋ฉด, ์—ฐ๊ฒฐ๋œ ์–‘์‹์— ์ž…๋ ฅํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•˜๊ฑฐ๋‚˜, ์ฒดํฌ or ์ฒดํฌ ํ•ด์ œ

โžก๏ธ <input>

  • ์‚ฌ์šฉ์ž๋กœ๋ถ€ํ„ฐ ์ž…๋ ฅ๋ฐ›์„ ์ˆ˜ ์žˆ๋Š” ์ž…๋ ฅ ํ•„๋“œ(input filed)๋ฅผ ์ •์˜ํ•  ๋•Œ ์‚ฌ์šฉ
  • ์‚ฌ์šฉ์ž๊ฐ€ ๋ฐ์ดํ„ฐ๋ฅผ ์ž…๋ ฅํ•  ์ˆ˜ ์žˆ๋Š” ์ž…๋ ฅ ํ•„๋“œ๋ฅผ ์„ ์–ธํ•˜๊ธฐ ์œ„ํ•ด <form> ์š”์†Œ ๋‚ด๋ถ€์—์„œ ์‚ฌ์šฉ
  • type ์†์„ฑ๊ฐ’์„ ๋‹ฌ๋ฆฌํ•จ์œผ๋กœ์จ ์—ฌ๋Ÿฌ ๊ฐ€์ง€ ๋ชจ์–‘์œผ๋กœ ๋‚˜ํƒ€๋‚ผ ์ˆ˜ ์žˆ์Œ
  • <label> ์„ ์‚ฌ์šฉํ•˜๋ฉด <input> ์˜ ๋ผ๋ฒจ(label)์„ ์ •์˜ํ•  ์ˆ˜ ์žˆ
<label for="first_name">์ด๋ฆ„</label>
<input type="text" id="first_name" name="first_name"><br>

 

 

ํ’€์ด๊ณผ์ •

1. ์›น์‚ฌ์ดํŠธ ์ด๋ฆ„ '๋‚˜๋Š” ์ตœ๊ฐ•์ด๋‹ค'๋กœ ์„ค์ •

<head>
	<title>๋‚˜๋Š” ์ตœ๊ฐ•์ด๋‹ค</title>
</head>

 

 

2. <h1>ํƒœ๊ทธ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ '์ตœ๊ฐ•์˜ ๊ฐœ๋ฐœ์ž ๋“ฑ๋ก'

<h1>์ตœ๊ฐ•์˜ ๊ฐœ๋ฐœ์ž ๋“ฑ๋ก</h1>

 

 

3. label๊ณผ input์˜ ๋‹ค์–‘ํ•œ type์„ ํ™œ์šฉ

1) type="text" : ์ด๋ฆ„/์„ฑ/์•„์ด๋”” ์ž…๋ ฅ์ฐฝ

๐Ÿ’ฅ'placeholder = ๋นˆ์นธ์ผ ๋•Œ ๋‚˜ํƒ€๋‚  ๊ธ€์ž'๋ฅผ ์„ค์ •ํ•˜์—ฌ ์•„๋ฌด๊ฒƒ๋„ ์ž…๋ ฅํ•˜์ง€ ์•Š์•˜์„ ๋•Œ ๊ธ€์ž๊ฐ€ ๋œจ๋„๋ก ์„ค์ •ํ•จ

<label for="first_name">์ด๋ฆ„</label>
<input type="text" id="first_name" name="first_name"  placeholder="์ด๋ฆ„"><br>
<label for="last_name">์„ฑ</label>
<input type="text" id="last_name" name="last_name" placeholder="์„ฑ"><br>
<label for="userId">์•„์ด๋””</label>
<input type="text" id="userId" name="userId" placeholder="์•„์ด๋””"><br>

 

 

2) type="email" : ์ด๋ฉ”์ผ ์ž…๋ ฅ์ฐฝ

๐Ÿ’ฅ'placeholder = ๋นˆ์นธ์ผ ๋•Œ ๋‚˜ํƒ€๋‚  ๊ธ€์ž'๋ฅผ ์„ค์ •ํ•˜์—ฌ ์•„๋ฌด๊ฒƒ๋„ ์ž…๋ ฅํ•˜์ง€ ์•Š์•˜์„ ๋•Œ ๊ธ€์ž๊ฐ€ ๋œจ๋„๋ก ์„ค์ •ํ•จ

<label for="email">์ด๋ฉ”์ผ</label>
<input type="email" id="email" name="email" placeholder="์ด๋ฉ”์ผ"><br>

 

 

3) type="password" : ๋น„๋ฐ€๋ฒˆํ˜ธ ์ž…๋ ฅ์ฐฝ

๐Ÿ’ฅ'placeholder = ๋นˆ์นธ์ผ ๋•Œ ๋‚˜ํƒ€๋‚  ๊ธ€์ž'๋ฅผ ์„ค์ •ํ•˜์—ฌ ์•„๋ฌด๊ฒƒ๋„ ์ž…๋ ฅํ•˜์ง€ ์•Š์•˜์„ ๋•Œ ๊ธ€์ž๊ฐ€ ๋œจ๋„๋ก ์„ค์ •ํ•จ

<label for="userPassowrd">๋น„๋ฐ€๋ฒˆํ˜ธ</label>
<input type="password" id="userPassowrd" name="userPassowrd" placeholder="๋น„๋ฐ€๋ฒˆํ˜ธ"><br>

 

 

4) type="data" : ์ƒ์ผ์„ ์ž…๋ ฅํ•  ์ˆ˜ ์žˆ๋Š” ๋‚ ์งœ ํผ

<label for="date">์ƒ์ผ</label>
<input type="date" id="date" max="2023-12-31" min="1900-01-01" value="mm/dd/yyyy"><br>

 

 

5) type="range" : ๊ตฌ๊ธ€๋ง ๋Šฅ๋ ฅ์„ range๋กœ ์ž…๋ ฅ๋ฐ›๊ธฐ

๐Ÿ’ฅ'tickmarks'๋ฅผ 1~10์‚ฌ์ด๋กœ ์„ค์ •ํ•˜์—ฌ range์— ๋ˆˆ๊ธˆ ํ‘œ์‹œ

<label for="google">๋‹น์‹ ์˜ ๊ตฌ๊ธ€๋ง ๋Šฅ๋ ฅ์€?</label>
<input type="range" id="google" name="google" min="1" max="10" list="tickmarks"><br>
<datalist id="tickmarks">
        <option value="1"></option>
        <option value="2"></option>
        <option value="3"></option>
        <option value="4"></option>
        <option value="5"></option>
        <option value="6"></option>
        <option value="7"></option>
        <option value="8"></option>
        <option value="9"></option>
        <option value="10"></option>
</datalist>

 

 

6) type="color" : ์ข‹์•„ํ•˜๋Š” ์ƒ‰๊น” ์„ ํƒํ•  ์ˆ˜ ์žˆ๋Š” ์ž…๋ ฅ์ฐฝ

<label for="myBestColor">๊ฐ€์žฅ ์ข‹์•„ํ•˜๋Š” ์ƒ‰๊น”์€?</label>
<input type='color' id='myBestColor' name="myBestColor" value='#000000'><br>

 

7) type="submit" : '๋“ฑ๋ก' ๋ฒ„ํŠผ ๋งŒ๋“ค๊ธฐ

<input type="submit" value="๋“ฑ๋ก">

 

 

4. ๊ฒฐ๊ณผ

<!DOCTYPE html>
<html>
<head>
	<title>๋‚˜๋Š” ์ตœ๊ฐ•์ด๋‹ค</title>
</head>
<body>
	<h1>์ตœ๊ฐ•์˜ ๊ฐœ๋ฐœ์ž ๋“ฑ๋ก</h1>
	<form action="#" method="post">
		<label for="first_name">์ด๋ฆ„</label>
		<input type="text" id="first_name" name="first_name"  placeholder="์ด๋ฆ„"><br>
        <label for="last_name">์„ฑ</label>
		<input type="text" id="last_name" name="last_name" placeholder="์„ฑ"><br>
		<label for="email">์ด๋ฉ”์ผ</label>
		<input type="email" id="email" name="email" placeholder="์ด๋ฉ”์ผ"><br>
        <label for="userId">์•„์ด๋””</label>
		<input type="text" id="userId" name="userId" placeholder="์•„์ด๋””"><br>
        <label for="userPassowrd">๋น„๋ฐ€๋ฒˆํ˜ธ</label>
		<input type="password" id="userPassowrd" name="userPassowrd" placeholder="๋น„๋ฐ€๋ฒˆํ˜ธ"><br>
        <label for="date">์ƒ์ผ</label>
        <input type="date" id="date" max="2023-12-31" min="1900-01-01" value="mm/dd/yyyy"><br>
        <label for="google">๋‹น์‹ ์˜ ๊ตฌ๊ธ€๋ง ๋Šฅ๋ ฅ์€?</label>
        <input type="range" id="google" name="google" min="1" max="10" list="tickmarks"><br>
        <datalist id="tickmarks">
            <option value="1"></option>
            <option value="2"></option>
            <option value="3"></option>
            <option value="4"></option>
            <option value="5"></option>
            <option value="6"></option>
            <option value="7"></option>
            <option value="8"></option>
            <option value="9"></option>
            <option value="10"></option>
        </datalist>
        <label for="myBestColor">๊ฐ€์žฅ ์ข‹์•„ํ•˜๋Š” ์ƒ‰๊น”์€?</label>
        <input type='color' id='myBestColor' name="myBestColor" value='#000000'><br>
		<input type="submit" value="๋“ฑ๋ก">
	</form>
</body>
</html>

 

 

๊ฒฐ๊ณผ


๋‚˜๋Š” ์ตœ๊ฐ•์ด๋‹ค

์ตœ๊ฐ•์˜ ๊ฐœ๋ฐœ์ž ๋“ฑ๋ก










ex01

์ œ์ถœ ๋””๋ ‰ํ† ๋ฆฌ : ex01/

์ œ์ถœ ํŒŒ์ผ : squareSquareBeam.html, leftHand_is.css

 

ํ™”๋ฉด๊ณผ ๋™์ผํ•œ ๊ฒฐ๊ณผ๊ฐ€ ๋‚˜์˜ค๋„๋ก css ํŒŒ์ผ์„ ์™„์„ฑ์‹œํ‚ค๊ณ , html ํŒŒ์ผ๊ณผ ํ•จ๊ป˜ ์ œ์ถœํ•˜์„ธ์š”

leftHand_is.css

html {
  background-color: tomato;
  ...
	...
	...
}

body {
	background-color: wheat;
  ...
	...
	...
}

.square {
  border: 3px solid white;
  ...
	...
	...
}

.square-mid {
  border: 3px dashed white;
  ...
	...
	...
}

 

๊ฒฐ๊ณผ)

 

โš ๏ธ ํ™”๋ฉด์— ์ฃผ์†Œ์ฐฝ์€ ์‹ ๊ฒฝ์“ฐ์ง€ ๋งˆ์„ธ์š”!

โš ๏ธ ๋ชจ๋“  ์‚ฌ๊ฐํ˜•์€ ๊ฐ€๋กœ, ์„ธ๋กœ ๊ฐ€์šด๋ฐ ์ •๋ ฌ ๋˜์–ด ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

โš ๏ธ ๋ฐ˜์‘ํ˜• ํŽ˜์ด์ง€๋กœ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”!

 

 

ํ’€์ด๊ณผ์ •

1. html ํŒŒ์ผ

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="./leftHand_is.css">
    <style>
        .square {
            margin-left: auto; margin-right: auto;
            margin-top: 35px; margin-bottom: 35px;
        }
        .square-mid {
            margin-left: auto; margin-right: auto;
        }
      </style>
<body>
    <div class="parent">
        <div class="square"></div>
        <div class="square-mid"></div>
        <div class="square"></div>
        <div class="square-mid"></div>
        <div class="square"></div>
    </div>
</body>
</html>

 

 

2. css ํŒŒ์ผ

  html {
    background-color: tomato;

  }

  body {
    background-color: wheat;
    width: 500px;
    height: 500px;
    position: absolute;
    top: 50%; left: 50%; transform: translate(-50%, -50%); 
    border: 3px solid black;
  }

  .square {
    border: 3px solid white;
    background-color: green;
    width: 100px;
    height: 50px;
  }

  .square-mid {
    border: 3px dashed white;
    background-color: green;
    width: 300px;
    height: 50px;
  }

ex02

์ œ์ถœ ๋””๋ ‰ํ† ๋ฆฌ : ex02/

์ œ์ถœ ํŒŒ์ผ : Calculator.html, Calculator.css, Calculator.js

 

๋ง์…ˆ, ๋บ„์…ˆ, ๊ณฑ์…ˆ, ๋‚˜๋ˆ—์…ˆ ๊ธฐ๋Šฅ์„ ๊ตฌํ˜„ํ•˜์—ฌ ๊ณ„์‚ฐ๊ธฐ๋ฅผ ๋งŒ๋“ค์–ด ๋ณด์‹œ์˜ค.

์˜ˆ์‹œ)

โš ๏ธ ๋””์ž์ธ์€ ์˜ˆ์‹œ์™€ ๋ฐ˜๋“œ์‹œ ์ผ์น˜ํ•˜์ง€ ์•Š์•„๋„ ๊ดœ์ฐฎ์Šต๋‹ˆ๋‹ค.

 

 

ํ’€์ด๊ณผ์ •

1. html ํŒŒ์ผ

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Calculator</title>
    <link rel="stylesheet" href="Calculator.css">
</head>
<body>
    <center>
        <h1>Calculator</h1>
    </center>
    <div class="calculator">
        <label for="first_number">First number:</label>
        <input type="text" id="num1" placeholder="Enter number 1">
        
        <label for="first_number">Second number:</label>
        <input type="text" id="num2" placeholder="Enter number 2">
        
        <br>
        <label for="Operator">Operator:</label>
        <button id="add" onclick="calculate('+')">+</button>
        <button id="subtract" onclick="calculate('-')">-</button>
        <button id="multiply" onclick="calculate('*')">*</button>
        <button id="divide" onclick="calculate('/')">/</button>
        <br>
    </div>

    <h1>Result:
    <input type="text" id="result"  
            style="border: none; background: transparent; font-size: 30px; font-weight: bold;"
            disabled>
    </h1>
    <script src="Calculator.js"></script>
</body>
</html>

 

 

2. css ํŒŒ์ผ

.calculator {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 300px;
    margin: 0 auto;
}

.calculator input {
    margin: 10px;
    padding: 10px;
    width: 100%;
}

.calculator button {
    margin: 10px;
    padding: 10px;
    width: 50px;
    font-size: 20px;
    border-radius: 5px;
    border: none;
    background-color: #ccc;
    color: #333;
    cursor: pointer;
}

.calculator button:hover {
    background-color: #333;
    color: #fff;
}

.calculator button:active {
    transform: translateY(1px);
}

 

 

3. javascript ํŒŒ์ผ

function calculate(operator) {
    var num1 = parseFloat(document.getElementById("num1").value);
    var num2 = parseFloat(document.getElementById("num2").value);
    var result;

    switch(operator) {
        case '+':
            result = num1 + num2;
            break;
        case '-':
            result = num1 - num2;
            break;
        case '*':
            result = num1 * num2;
            break;
        case '/':
            result = num1 / num2;
            break;
    }

    document.getElementById("result").value = result;
}

 

 

4. ๊ฒฐ๊ณผ


ex03

์ œ์ถœ ๋””๋ ‰ํ† ๋ฆฌ : ex03/

์ œ์ถœ ํŒŒ์ผ : Alarm.html, Alarm.css, Alarm.js

 

์ •ํ•ด์ง„ ์‹œ๊ฐ„์ด ๋˜๋ฉด ์•Œ๋žŒ์„ ๋„์šฐ๋Š” ํŽ˜์ด์ง€๋ฅผ ๋งŒ๋“ค์–ด๋ณด์„ธ์š”.

์˜ˆ์‹œ)

โš ๏ธ ๋””์ž์ธ์€ ์˜ˆ์‹œ์™€ ๋ฐ˜๋“œ์‹œ ์ผ์น˜ํ•˜์ง€ ์•Š์•„๋„ ๊ดœ์ฐฎ์Šต๋‹ˆ๋‹ค.

โš ๏ธ ์ฐธ๊ณ ๋กœ ์•Œ๋ฆผ์ด ๊ณ„์† ๋œจ๋ฉด ์•ˆ๋ฉ๋‹ˆ๋‹ค~~~

 

 

๐Ÿ’ก ํ•„์š”ํ•œ javascript ๋ฌธ๋ฒ•

โžก๏ธ setTimeout(callback, delayTime)

์ฝœ๋ฐฑ ํ•จ์ˆ˜์™€ ์ง€์ฒดํ•  ์‹œ๊ฐ„์„ ์ธ์ž๋กœ ๋ฐ›์•„, ์ธ์ž๋กœ ๋ฐ›์€ ์‹œ๊ฐ„๋งŒํผ ๊ธฐ๋‹ค๋ ธ๋‹ค๊ฐ€ ์ฝœ๋ฐฑ ํ•จ์ˆ˜๋ฅผ ์‹คํ–‰ํ•˜๋Š” JS ๋‚ด์žฅ ํ•จ์ˆ˜

/* sample 17 */
// 1๋ฒˆ ํ•จ์ˆ˜
setTimeout(()=>{
    console.log('todo: First Work!');
}, 3000);

// 2๋ฒˆ ํ•จ์ˆ˜
setTimeout(()=>{
    console.log('todo: Second Work!');
}, 2000);

// ์ถœ๋ ฅ๊ฒฐ๊ณผ
/*
todo: Second Work!
todo: First Work!
*/

 

โžก๏ธ ์ฐธ๊ณ 

https://steadily-hyunjin.tistory.com/49

 

[JavaScript] ๊ธฐ์ดˆ๋ฌธ๋ฒ•-2 (alert, prompt, confirm / ํ˜•๋ณ€ํ™˜)

[JavaScript] ๊ธฐ์ดˆ๋ฌธ๋ฒ•-2 (alert, prompt, confirm / ํ˜•๋ณ€ํ™˜) โœ… ์‚ฌ์šฉ์ž ์ธํ„ฐํŽ˜์ด์Šค ๊ธฐ๋Šฅ (alert / prompt / comfirm) โ–ถ alert : ์•Œ๋ ค์คŒ โ–ถ prompt : ์ž…๋ ฅ ๋ฐ›์Œ โ–ถ confirm : ํ™•์ธ ๋ฐ›์Œ 1. alert('message'); - ํ™•์ธ ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅผ ๋•Œ

steadily-hyunjin.tistory.com

https://steadily-hyunjin.tistory.com/67

 

[Node.js๋กœ ์„œ๋ฒ„๋งŒ๋“ค๊ธฐ] 2. ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ๊ธฐ๋ณธ ๋ฌธ๋ฒ• (์ฝœ๋ฐฑ ํ•จ์ˆ˜/Promise/async/await)

โœ… ์ฝœ๋ฐฑ ํ•จ์ˆ˜ ์ฝœ๋ฐฑ์ด๋ž€? ๋‚˜์ค‘์— ์‹คํ–‰๋˜๋Š” ์ฝ”๋“œ ์˜ˆ์‹œ 1) A()๋ผ๋Š” ํ•จ์ˆ˜์— ์ธ์ž๋กœ ์–ด๋–ค ํ•จ์ˆ˜๋ฅผ ๋„ฃ์–ด์คŒ. (์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ์—์„œ ํ•จ์ˆ˜๋Š” '์ผ๊ธ‰ ๊ฐ์ฒด'์ด๋ฏ€๋กœ ์ธ์ž๋กœ ํ•จ์ˆ˜๋ฅผ ๋„ฃ์–ด์ฃผ๋Š” ๊ฒƒ์ด ๊ฐ€๋Šฅํ•จ) 2) A ํ•จ์ˆ˜์˜

steadily-hyunjin.tistory.com

 

 

ํ’€์ด๊ณผ์ •

1. html ํŒŒ์ผ

<!DOCTYPE html>
<html>
<head>
	<title>์•Œ๋žŒ</title>
	<link rel="stylesheet" type="text/css" href="Alarm.css">
</head>
<body>
	<center>
	<h1>Alarm Clock</h1>
	<label for="alarmTime">Set the alarm time:</label>
	<br>
	<input type="time" id="alarmTime" name="alarmTime">
	<button id="setAlarmBtn">Set<br>Alarm</button>

	<script type="text/javascript" src="Alarm.js"></script>
</center>
</body>
</html>

 

2. css ํŒŒ์ผ

h1 {
    font-size: 50px;
    font-weight: bold;
    margin-top: 30px;
    margin-bottom: 10px;
    text-align: center;
  }
  
  button {
    display: block;
    margin: 0 auto;
    margin-top: 20px;
    padding: 10px;
    font-size: 16px;
    font-weight: bold;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
  }

 

3. javascript ํŒŒ์ผ

: setTimeout(callback, delayTime) ํ•จ์ˆ˜๋ฅผ ํ™œ์šฉํ•˜์—ฌ

alarmTime - now์˜ ๊ฐ’์ด 0์ด ๋˜๋ฉด,

์ฆ‰, ํ˜„์žฌ์‹œ๊ฐ„์ด ์•Œ๋žŒ์‹œ๊ฐ„์œผ๋กœ ์„ค์ •ํ•œ ์‹œ๊ฐ„๊ณผ ๊ฐ™๋‹ค๋ฉด

"์•Œ๋žŒ์ด ์šธ๋ฆฝ๋‹ˆ๋‹ค"๋ฅผ alert์œผ๋กœ ์ถœ๋ ฅํ•จ.

const setAlarmBtn = document.getElementById("setAlarmBtn");

setAlarmBtn.addEventListener("click", () => {
    const alarmInput = document.getElementById("alarmTime").value;
    const [hours, minutes] = alarmInput.split(":");
    const alarmTime = new Date();
    alarmTime.setHours(hours);
    alarmTime.setMinutes(minutes);
    alarmTime.setSeconds(0);
    alarmTime.setMilliseconds(0);
  const now = new Date();
  alert(alarmInput + "์œผ๋กœ ์•Œ๋žŒ์„ ์„ค์ •ํ–ˆ์Šต๋‹ˆ๋‹ค.");

  if (isNaN(alarmTime)) {
    alert("์ž˜๋ชป๋œ ์‹œ๊ฐ„ ํ˜•์‹์ž…๋‹ˆ๋‹ค. ๋‹ค์‹œ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.");
    return;
  }

  if (alarmTime <= now) {
    alert("์•Œ๋žŒ ์‹œ๊ฐ„์€ ํ˜„์žฌ ์‹œ๊ฐ„ ์ดํ›„๋กœ ์„ค์ •ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.");
    return;
  }

  const timeUntilAlarm = alarmTime - now;
  setTimeout(() => {
    alert("์•Œ๋žŒ์ด ์šธ๋ฆฝ๋‹ˆ๋‹ค!");
  }, timeUntilAlarm);
});

 

4. ๊ฒฐ๊ณผ


Bonus

์ œ์ถœ ๋””๋ ‰ํ† ๋ฆฌ : bonus/

์ œ์ถœ ํŒŒ์ผ : sudoku.html, sudoku.css, sudoku.js

 

ํ˜น์‹œ ๊ฒŒ์ž„ ์ข‹์•„ํ•˜์‹œ๋‚˜์š”? ์Šค๋„์ฟ  ๊ฒŒ์ž„์„ ๋งŒ๋“ค์–ด ๋ด…์‹œ๋‹ค!

  1. ์Šค๋„์ฟ  ํ…Œ์ด๋ธ”์˜ ํฌ๊ธฐ๋Š” 9 * 9๋กœ ๊ณ ์ •ํ•ฉ๋‹ˆ๋‹ค.
  2. ํ…Œ์ด๋ธ”์˜ ๊ฐ ์‰˜์€ 1~9์˜ ์ˆซ์ž๋กœ ์ฑ„์›Œ์ ธ์•ผ ํ•ฉ๋‹ˆ๋‹ค.
  3. ์Šค๋„์ฟ ๋ฅผ ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ์™„์„ฑํ–ˆ๋Š”์ง€ ์ฑ„์ ํ•˜๋Š” ๋ฒ„ํŠผ์ด ์žˆ์–ด์•ผํ•ฉ๋‹ˆ๋‹ค.

โš ๏ธ ๋””์ž์ธ์€ ์—ฌ๋Ÿฌ๋ถ„์ด ์ž์œ ๋กญ๊ฒŒ ๊ตฌํ˜„ํ•˜์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค! ๋‹จ, ๋„ˆ๋ฌด ๋ชป์ƒ๊ธฐ์ง€๋งŒ ์•Š์œผ๋ฉด ์ข‹๊ฒ ์–ด์š”

 

 

ํ’€์ด๊ณผ์ •

1. html ํŒŒ์ผ

<!DOCTYPE html>
<html>
<head>
	<title>SDOKU</title>
    <link rel="stylesheet" href="sdoku.css">
</head>
<body>
	<h1>SDOKU Table</h1>
	<table>
		<thead>
			<tr>
				<th>Random Number</th>
			</tr>
		</thead>
		<tbody id="table-body">
		</tbody>
	</table>
	<button onclick="generateTable()">Generate Table</button>
	<script src="sdoku.js"></script>
</body>
</html>

 

2. css ํŒŒ์ผ

table {
  border-collapse: collapse;
  margin: 20px;
}
td {
  border: 1px solid black;
  padding: 10px;
  text-align: center;
}

 

3. javascript ํŒŒ์ผ

let puzzle = new Array(9);

function create_puzzle(){
    for (var i = 0; i < puzzle.length; i++) {
        puzzle[i] = new Array(9).fill(0);
    }
}

function create_sudoku(){
    create_puzzle();
    
    let rand_number;
    let ok;
    for(let i = 0;i<9;i++){
        for(let j=0;j<9;j++){
            ok = true;
            rand_number = Math.floor(Math.random() * 9 + 1);

            // ๊ฐ€๋กœ ์ฒดํฌ
            for (k = 0; k < j; k++) {
                if (puzzle[i][k] == rand_number) {
                    --j;
                    ok=false;
                    break;
                }
            }

            // ์„ธ๋กœ ์ฒดํฌ
            for (k=0; k<i;k++){
                if(puzzle[k][j] == rand_number){
                    --j;
                    ok=false;
                    break;
                }
            }

            // 3x3 ์ฒดํฌ
            let sero = Math.floor(i/3)*3;
            let garo = Math.floor(j/3)*3;

            for(x = sero; x<sero+3; x++){
                for(y = garo; y<garo+3; y++){
                    if((x==i) && (y==j)) continue;
                    if(puzzle[x][y] == rand_number){
                        --j;
                        ok=false;
                        break;
                    }
                    if(ok==false) break;
                }
            }

            if(ok) puzzle[i][j] = rand_number;
        }
    }
}


function generateTable() {
  create_sudoku();

  var tableBody = document.getElementById("table-body");
  tableBody.innerHTML = "";
  for (var i = 0; i < 9; i++) {
      var row = document.createElement("tr");
      for (var j = 0; j < 9; j++) {
          var cell = document.createElement("td");
          cell.textContent = puzzle[i][j];
          row.appendChild(cell);
      }
      tableBody.appendChild(row);
  }
}