๋ฉํฐ๋ฏธ๋์ด ํ๊ทธ
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
๊ทธ๋ํฝ์ ๊ทธ๋ฆฌ๊ฑฐ๋ ์ ๋๋ฉ์ด์
์ ๋ง๋ค ์ ์๋ ์์ญ์ ์ ๊ณตํฉ๋๋ค.
ํ๊ทธ | ์์ฑ | ์ค๋ช
| ์์ |
<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
๋ณต์ฌ