Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!-- サムネイルとして表示される動画 -->
<video class="popup" src="https://web-create-kokusyo.com/wp-content/uploads/2024/03/mov_hts-samp003.mp4" type="video/mp4"></video>
<video class="popup" src="https://web-create-kokusyo.com/wp-content/uploads/2024/03/mov_hts-samp005.mp4" type="video/mp4"></video>


<div id="modal" class="modal">
    <!-- モーダルでフルサイズで表示される動画コンテナ -->
    <div id="modalContent" class="modal-content">
        <!-- 事前にmodal内にvideo要素を配置 -->
        <video id="modalVideo" controls style="width: 100%;">
            <source id="videoSource" type="video/mp4">
        </video>
    </div>
    <span id="close">&times;</span>
</div>
              
            
!

CSS

              
                .modal {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    z-index: 1;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4); /* 背景色 */
    opacity: 0; /* 初期状態では透明 */
    visibility: hidden; /* 初期状態では不可視 */
    transition: opacity 0.5s, visibility 0.5s; /* アニメーション効果 */
}

.modal-content {
    display: block;
    width: 80%;
    max-width: 700px;
}

#close {
    position: absolute;
    top: 15px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
}

video {
    width: 200px;
    cursor: pointer;
}

              
            
!

JS

              
                const modal = document.getElementById('modal');
const videos = document.querySelectorAll('.popup'); // ここは動画を示す要素に適したセレクタに変更してください
const modalVideo = document.getElementById('modalVideo');
const closeSpan = document.getElementById('close'); // 閉じるボタンの処理は既に設定されているとします

for (let video of videos) {
    video.onclick = function() {
        modal.style.opacity = "1";
        modal.style.visibility = "visible";
        console.log(this.src)
        modalVideo.src = this.src; // ここで直接クリックされたvideoのsrcを取得
        modalVideo.load(); // 新しいソースを読み込む
        modalVideo.play(); // 動画を再生
    }
}

closeSpan.onclick = function() {
    modal.style.opacity = "0";
    modal.style.visibility = "hidden";
    modalVideo.pause(); // モーダルを閉じると動画を停止
}

window.onclick = function(event) {
    if (event.target == modal) {
        modal.style.opacity = "0";
        modal.style.visibility = "hidden";
        modalVideo.pause(); // モーダルを閉じると動画を停止
    }
};
              
            
!
999px

Console