: 로딩 창 및 동영상 삽입 구현
setTimeout()
함수를 통해 로딩 페이지에서 5초 뒤 동영상 페이지로 전환하기display: none
display: flex
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="main.css">
<style>
@import url('https://fonts.googleapis.com/css2?family=Nanum+Myeongjo&display=swap');
</style>
<title>Loading</title>
</head>
<body>
<!-- 로딩 페이지 -->
<div id="loading">
<img src="Walk.gif" alt="My image">
<p id="loadingtitle">Loading...</p>
</div>
<!-- 동영상 페이지 -->
<div id="video" style="display: none;">
<p id="title">Someday or One Day</p>
<iframe width="560" height="315" src="https://www.youtube.com/embed/eHPxNwEWHpg?loop=1&autoplay=1&mute=1si=UYsNbT9Hi6Mqt6B0" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
</div>
<script src="index.js"></script>
</body>
</html>
index.js
setTimeout(() => {
document.getElementById('loading').style.display = 'none';
document.getElementById('video').style.display = 'flex';
}, 5000);
main.css
#loading, #video {
display: flex;
justify-content: center;
align-items: center;
text-align: center;
flex-direction: column;
height: 100vh;
overflow: hidden;
}
#title {
font-family: "Nanum Myeongjo", serif;
font-size: 20px;
font-weight: 500;
margin-bottom: 35px;
}
<iframe>
: 유튜브 동영상을 첨부할 때 사용하는 태그
src
: 삽입할 홈페이지 좌표name
: 프레임 이름width
: 프레임 가로 너비height
: 프레임 세로 길이mute=1
: 뮤트autoplay=1
: 자동재생loop=1
: 반복playlist
값을 설정)<iframe width="560" height="315"
src="https://www.youtube.com/embed/kamsx_g2hnI?loop=1&autoplay=1&mute=1&playlist=kamsx_g2hnI" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen>
</iframe>
https://github.com/kwonboryong/toyProjects/tree/main/loading%26video
https://codepen.io/Beluga-CAT-meow/pen/yLwWrEB
https://jong99.tistory.com/m/36