Jquery

[HTML/CSS] 로딩팝업정리

Stater 2025. 2. 23. 08:31

[ index.html ]

<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>파일 다운로드</title>
    <style>
        /* 팝업 스타일 */
        #loadingPopup {
            display: none;
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 300px;
            height: 150px;
            background: rgba(0, 0, 0, 0.8);
            color: white;
            text-align: center;
            padding: 20px;
            border-radius: 10px;
            z-index: 1000;
        }
        /* 로딩 GIF 스타일 */
        #loadingPopup img {
            width: 50px;
            height: 50px;
            margin-top: 10px;
        }
        /* 배경 어둡게 효과 */
        #overlay {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.5);
            z-index: 999;
        }
    </style>
    <script>
        function showLoadingPopup() {
            document.getElementById("loadingPopup").style.display = "block";
            document.getElementById("overlay").style.display = "block";

            setTimeout(() => {
                document.getElementById("loadingPopup").style.display = "none";
                document.getElementById("overlay").style.display = "none";
            }, 2000);
        }
    </script>
</head>
<body>

    <h2>파일 다운로드</h2>
    <button onclick="showLoadingPopup()">파일 다운로드</button>

    <!-- 어두운 배경 -->
    <div id="overlay"></div>

    <!-- 로딩 팝업 -->
    <div id="loadingPopup">
        <h3>파일을 다운로드 중...</h3>
        <img src="loading.gif" alt="로딩 중...">
    </div>

</body>
</html>

 

[ loading.html]

<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>다운로드 중...</title>
    <script>
        function closePopup() {
            setTimeout(() => {
                window.close(); // 2초 후 팝업 자동 종료
            }, 2000);
        }

        window.onload = closePopup;
    </script>
</head>
<body>

<h3>파일을 다운로드 중입니다...</h3>
<div>
    <img src="loading.gif" alt="로딩 중...">
</div>

</body>
</html>

로딩이미지

반응형

'Jquery' 카테고리의 다른 글

[Javascript] 체크박스  (1) 2024.09.13
[Javascript] 체크박스  (0) 2024.09.13
Jquery attribute vs props vs data 차이  (0) 2019.05.03