Search

λ©€ν‹°λ―Έλ””μ–΄ νƒœκ·Έ

λ©€ν‹°λ―Έλ””μ–΄ νƒœκ·Έ

HTMLμ—μ„œ μ˜€λ””μ˜€, λΉ„λ””μ˜€, κ·Έλž˜ν”½ λ“± λ‹€μ–‘ν•œ λ©€ν‹°λ―Έλ””μ–΄ μ½˜ν…μΈ λ₯Ό μ›Ή νŽ˜μ΄μ§€μ— μ‚½μž…ν•˜κ±°λ‚˜ μ œμ–΄ν•  수 μžˆλŠ” νƒœκ·Έλ₯Ό λ§ν•©λ‹ˆλ‹€.
β€’
audio
β€’
video
β€’
iframe
β€’
canvas

audio

μ›Ή νŽ˜μ΄μ§€μ—μ„œ μ˜€λ””μ˜€ νŒŒμΌμ„ μž¬μƒν•  수 μžˆλŠ” νƒœκ·Έμž…λ‹ˆλ‹€.
νƒœκ·Έ
속성
μ„€λͺ…
μ˜ˆμ‹œ
<audio>
src
μ˜€λ””μ˜€ 파일의 URL을 지정
<audio src="sound.mp3"></audio>
controls
κΈ°λ³Έ μ˜€λ””μ˜€ 컨트둀(μž¬μƒ, μΌμ‹œ 정지 λ“±)을 ν‘œμ‹œ
<audio controls></audio>
autoplay
νŽ˜μ΄μ§€ λ‘œλ“œ μ‹œ μžλ™μœΌλ‘œ μ˜€λ””μ˜€λ₯Ό μž¬μƒ
<audio src="sound.mp3" autoplay></audio>
loop
μ˜€λ””μ˜€κ°€ λλ‚œ ν›„ μžλ™μœΌλ‘œ λ‹€μ‹œ μ‹œμž‘
<audio src="sound.mp3" loop></audio>
muted
μ˜€λ””μ˜€λ₯Ό μŒμ†Œκ±° μƒνƒœλ‘œ μ„€μ •
<audio src="sound.mp3" muted></audio>
preload
νŽ˜μ΄μ§€ λ‘œλ“œ μ‹œ μ˜€λ””μ˜€λ₯Ό 미리 λ‘œλ“œν• μ§€ μ—¬λΆ€λ₯Ό μ„€μ • (auto, metadata, none)
<audio src="sound.mp3" preload="auto"></audio>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>μ˜€λ””μ˜€ νƒœκ·Έ</title> </head> <body> <!-- audio νƒœκ·Έ 속성 - autoplay : μžλ™μž¬μƒ - controls : μ˜€λ””μ˜€ μž¬μƒ/λ³Όλ₯¨ 컨트둀 ν‘œμ‹œ - loop : λ°˜λ³΅μž¬μƒ - preload : μ˜€λ””μ˜€ 파일 미리 λ‹€μš΄λ‘œλ“œ - src : μž¬μƒν•  μ˜€λ””μ˜€ 파일 경둜 - volume : μž¬μƒ λ³Όλ₯¨ 크기 ( 0.0~1.0 ) - audio format(파일 포맷) : mp3, ogg, wav - MIME type(파일 ν˜•μ‹) : audio/mp3, audio/ogg, audio/wav --> <h1>audio νƒœκ·Έ</h1> <audio src="audio/bgm.mp3" controls></audio> <h1>ν™•μž₯자 ν˜Έν™˜</h1> <audio controls autoplay> <source src="audio/bgm.mp3" type="audio/mp3"> <source src="audio/bgm.ogg" type="audio/ogg"> <source src="audio/bgm.wav" type="audio/wav"> </audio> <!-- source : λΈŒλΌμš°μ €λ§ˆλ‹€ μ§€μ›ν•˜λŠ” μ˜€λ””μ˜€ 파일 ν˜•μ‹μ„ ν˜Έν™˜μ‹œμΌœμ£ΌκΈ° μœ„ν•œ νƒœκ·Έ --> </body> </html>
HTML
볡사

video

μ›Ή νŽ˜μ΄μ§€μ—μ„œ λΉ„λ””μ˜€ νŒŒμΌμ„ μž¬μƒν•  수 μžˆλŠ” νƒœκ·Έμž…λ‹ˆλ‹€.
νƒœκ·Έ
속성
μ„€λͺ…
μ˜ˆμ‹œ
<video>
src
λΉ„λ””μ˜€ 파일의 URL을 지정
<video src="movie.mp4"></video>
controls
κΈ°λ³Έ λΉ„λ””μ˜€ 컨트둀(μž¬μƒ, μΌμ‹œ 정지 λ“±)을 ν‘œμ‹œ
<video controls></video>
autoplay
νŽ˜μ΄μ§€ λ‘œλ“œ μ‹œ μžλ™μœΌλ‘œ λΉ„λ””μ˜€λ₯Ό μž¬μƒ
<video src="movie.mp4" autoplay></video>
loop
λΉ„λ””μ˜€κ°€ λλ‚œ ν›„ μžλ™μœΌλ‘œ λ‹€μ‹œ μ‹œμž‘
<video src="movie.mp4" loop></video>
muted
λΉ„λ””μ˜€μ˜ μ†Œλ¦¬λ₯Ό μŒμ†Œκ±° μƒνƒœλ‘œ μ„€μ •
<video src="movie.mp4" muted></video>
preload
νŽ˜μ΄μ§€ λ‘œλ“œ μ‹œ λΉ„λ””μ˜€λ₯Ό 미리 λ‘œλ“œν• μ§€ μ—¬λΆ€λ₯Ό μ„€μ • (auto, metadata, none)
<video src="movie.mp4" preload="auto"></video>
width
λΉ„λ””μ˜€μ˜ κ°€λ‘œ 크기λ₯Ό μ„€μ •
<video src="movie.mp4" width="640"></video>
height
λΉ„λ””μ˜€μ˜ μ„Έλ‘œ 크기λ₯Ό μ„€μ •
<video src="movie.mp4" height="360"></video>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>λΉ„λ””μ˜€ νƒœκ·Έ</title> </head> <body> <!-- video νƒœκ·Έ 속성 - autoplay : μžλ™μž¬μƒ - controls : μ˜€λ””μ˜€ μž¬μƒ/λ³Όλ₯¨ 컨트둀 ν‘œμ‹œ - loop : λ°˜λ³΅μž¬μƒ - preload : 파일 미리 λ‹€μš΄λ‘œλ“œ - src : μž¬μƒν•  μ˜€λ””μ˜€ 파일 경둜 - volume : μž¬μƒ λ³Όλ₯¨ 크기 ( 0.0~1.0 ) - poster : 썸넀일 이미지 - muted : λΉ„λ””μ˜€μ˜ μ˜€λ””μ˜€ μŒμ†Œκ±° - width/height : λΉ„λ””μ˜€ κ°€λ‘œ μ„Έλ‘œ μ‚¬μ΄μ¦ˆ - video format(파일포맷) : mp4, webm, ogg - MIME type (νŒŒμΌν˜•μ‹) : video/mp4, video/webm, video/ogg --> <h1>video νƒœκ·Έ</h1> <video src="video/video.mp4" autoplay controls width="1024" height="768"></video> <h1>ν™•μž₯자 ν˜Έν™˜</h1> <video width="1024" height="768" controls> <source src="video/video.mp4" type="video/mp4"> <source src="video/video.ogg" type="video/ogg"> <source src="video/video.webm" type="video/webm"> </video> <h1>썸넀일</h1> <video src="video/video.mp4" controls width="1024" height="768" poster="img/poster.png"></video> <div style="height: 500px;"></div> </body> </html>
HTML
볡사

iframe

λ‹€λ₯Έ μ›Ή νŽ˜μ΄μ§€λ₯Ό ν˜„μž¬ νŽ˜μ΄μ§€ 내에 μ‚½μž…ν•  수 μžˆλŠ” νƒœκ·Έμž…λ‹ˆλ‹€.
νƒœκ·Έ
속성
μ„€λͺ…
μ˜ˆμ‹œ
<iframe>
src
iframe의 μ½˜ν…μΈ λ₯Ό λ‘œλ“œν•  URL을 지정
<iframe src="https://example.com"></iframe>
width
iframe의 κ°€λ‘œ 크기λ₯Ό μ„€μ •
<iframe src="https://example.com" width="600"></iframe>
height
iframe의 μ„Έλ‘œ 크기λ₯Ό μ„€μ •
<iframe src="https://example.com" height="400"></iframe>
title
iframe의 μ½˜ν…μΈ λ₯Ό μ„€λͺ…ν•˜λŠ” 제λͺ©μ„ μ„€μ •
<iframe src="https://example.com" title="Description"></iframe>
frameborder
iframe의 ν…Œλ‘λ¦¬ μ„€μ • (0 λ˜λŠ” 1)
<iframe src="https://example.com" frameborder="0"></iframe>
allowfullscreen
iframe의 μ½˜ν…μΈ λ₯Ό 전체 ν™”λ©΄ λͺ¨λ“œλ‘œ ν‘œμ‹œν•  수 있게 ν—ˆμš©
<iframe src="https://example.com" allowfullscreen></iframe>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>iframe</title> </head> <body> <!-- iframe (inline frame) : μ›Ή νŽ˜μ΄μ§€ μ•ˆμ—μ„œ λ‹€λ₯Έ μ›Ή νŽ˜μ΄μ§€λ₯Ό ν‘œμ‹œν•˜λŠ” νƒœκ·Έ - name 속성을 μ§€μ •ν•˜λ©΄ target ν”„λ ˆμž„μœΌλ‘œ μ‚¬μš©ν•  수 μžˆλ‹€ - naver, google λ“± 일뢀 μ‚¬μ΄νŠΈμ—μ„œλŠ” iframe 을 톡해 접근을 막고 μžˆλ‹€. --> <h1>λ‚΄λΆ€ νŽ˜μ΄μ§€ 및 μ™ΈλΆ€ νŽ˜μ΄μ§€ ν‘œμ‹œν•˜κΈ°</h1> <iframe src="03_inner.html" width="400" height="240"></iframe> <iframe src="http://www.tcpschool.com" width="400" height="240"></iframe> <hr> <h3>target ν”„λ ˆμž„μœΌλ‘œ ν‘œμ‹œν•˜κΈ°</h3> <iframe src="" name="frame1" width="400" height="240"></iframe> <p> <a href="http://typingclub.com" target="frame1">μ˜νƒ€ μ‚¬μ΄νŠΈ</a> </p> <iframe src="" name="frame2" width="400" height="240"></iframe> <p> <a href="http://hancomtyping.com" target="frame2">ν•œνƒ€ μ‚¬μ΄νŠΈ</a> </p> <h3>Youtube λ™μ˜μƒ ν‘œμ‹œν•˜κΈ°</h3> <iframe width="560" height="315" src="https://www.youtube.com/embed/zsA3gixXHNk?si=9_tpK6zy8vjqDHIW" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe> <div style="height: 500px;"></div> </body> </html>
HTML
볡사

canvas

κ·Έλž˜ν”½μ„ κ·Έλ¦¬κ±°λ‚˜ μ• λ‹ˆλ©”μ΄μ…˜μ„ λ§Œλ“€ 수 μžˆλŠ” μ˜μ—­μ„ μ œκ³΅ν•©λ‹ˆλ‹€.
JavaScript와 ν•¨κ»˜ μ‚¬μš©λ˜μ–΄ 동적인 κ·Έλž˜ν”½μ„ 생성할 수 μžˆμŠ΅λ‹ˆλ‹€.
νƒœκ·Έ
속성
μ„€λͺ…
μ˜ˆμ‹œ
<canvas>
width
μΊ”λ²„μŠ€μ˜ κ°€λ‘œ 크기λ₯Ό μ„€μ •
<canvas width="500"></canvas>
height
μΊ”λ²„μŠ€μ˜ μ„Έλ‘œ 크기λ₯Ό μ„€μ •
<canvas height="300"></canvas>
id
μΊ”λ²„μŠ€ μš”μ†Œμ˜ μ‹λ³„μž
<canvas id="myCanvas"></canvas>
style
μΊ”λ²„μŠ€μ˜ CSS μŠ€νƒ€μΌμ„ μ„€μ •
<canvas style="border:1px solid #000;"></canvas>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>λΈŒλŸ¬μ‹œλ‘œ κ·Έλ¦Ό 그리기</title> <style> canvas { border: 1px solid black; display: block; margin: 0 auto; background-color: #f0f0f0; } .controls { text-align: center; margin: 20px; } button { margin: 0 10px; padding: 10px 20px; font-size: 16px; cursor: pointer; } </style> </head> <body> <div class="controls"> <button id="clearBtn">전체 μ§€μš°κΈ°</button> <button id="saveBtn">그림으둜 μ €μž₯ν•˜κΈ°</button> </div> <canvas id="myCanvas" width="800" height="600"></canvas> <script> const canvas = document.getElementById('myCanvas'); const ctx = canvas.getContext('2d'); let drawing = false; // 마우슀 λ‹€μš΄ 이벀트 ν•Έλ“€λŸ¬ canvas.addEventListener('mousedown', (e) => { drawing = true; ctx.beginPath(); ctx.moveTo(e.clientX - canvas.offsetLeft, e.clientY - canvas.offsetTop); }); // 마우슀 μ—… 이벀트 ν•Έλ“€λŸ¬ canvas.addEventListener('mouseup', () => { drawing = false; }); // 마우슀 이동 이벀트 ν•Έλ“€λŸ¬ canvas.addEventListener('mousemove', (e) => { if (drawing) { ctx.lineTo(e.clientX - canvas.offsetLeft, e.clientY - canvas.offsetTop); ctx.strokeStyle = 'black'; // μ„  색상 ctx.lineWidth = 5; // μ„  λ‘κ»˜ ctx.lineCap = 'round'; // μ„  끝 λͺ¨μ–‘ ctx.stroke(); } }); // 마우슀 λ– λ‚˜κΈ° 이벀트 ν•Έλ“€λŸ¬ canvas.addEventListener('mouseleave', () => { if (drawing) { drawing = false; } }); // 전체 μ§€μš°κΈ° λ²„νŠΌ 이벀트 ν•Έλ“€λŸ¬ document.getElementById('clearBtn').addEventListener('click', () => { ctx.clearRect(0, 0, canvas.width, canvas.height); }); // 그림으둜 μ €μž₯ν•˜κΈ° λ²„νŠΌ 이벀트 ν•Έλ“€λŸ¬ document.getElementById('saveBtn').addEventListener('click', () => { const link = document.createElement('a'); link.href = canvas.toDataURL('image/png'); link.download = 'drawing.png'; link.click(); }); </script> </body> </html>
HTML
볡사