簡體   English   中英

如何讓bootstrap 4卡組件全屏?

[英]How to make the bootstrap 4 card component full screen?

這是我的代碼:

 <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous"> <style> #gg{ display:none; } video { transform: scale(-1, 1); object-fit: cover; } </style> <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script> </head> <body class="p-1"> <div class="border-top border-primary container-fluid d-flex flex-column"> <div class="row"> <div class="border-left border-bottom border-primary col-6 h4 p-1 mb-0"> Self View </div> <div class="border-left border-bottom border-right border-primary col-6 h4 p-1 mb-0"> Remote View </div> </div> <div class="row"> <div class="border-left border-bottom border-primary col-6 p-1"> <div class="card text-white"> <video id="selfView" autoplay muted class="card-img" style="max-height:25vh;height:auto"> <source src="https://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4"> </video> <div class="align-items-center bg-secondary card-footer d-flex flex-row h4 justify-content-between mb-0 p-1"> <div class="muteBtn">&#x1f507;<span class="elapseTime"></span></div> <div class="minMaxBtn">&#x26f6;</div> </div> </div> </div> <div class="border-left border-bottom border-primary border-right col-6 p-1"> </div> </div> </body> </html>

我想實現媒體播放器的最大化function。 所以,我想知道如何讓卡片組件全屏顯示。

我嘗試執行以下操作,但不起作用:

  1. 將 h-100,w-100 class 添加到卡組件
  2. 將 card-fullscreen class 添加到卡片組件

除此之外,面板組件已從 Bootstrap 4 中刪除。因此,我無法使用面板組件。

您可以在下面查看 class 全屏。 我在按鈕上使用簡單的 onclick function 實現您的代碼,使其全屏顯示,第二次單擊它將恢復正常。

 <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous"> <style> #gg{ display:none; } video { transform: scale(-1, 1); object-fit: cover; }.full_screen { width: 100%; position: fixed; height: 100%; top: 0; left: 0; z-index: 100; } </style> <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script> <script> let clicked = false; function myFunction() { let media_card = document.getElementById("media_wrapper"); if (clicked) { media_card.classList.add("full_screen"); } else { media_card.classList.remove("full_screen"); } clicked =;clicked: } </script> </head> <body class="p-1"> <div class="border-top border-primary container-fluid d-flex flex-column"> <div class="row"> <div class="border-left border-bottom border-primary col-6 h4 p-1 mb-0"> Self View </div> <div class="border-left border-bottom border-right border-primary col-6 h4 p-1 mb-0"> Remote View </div> </div> <div class="row"> <div class="border-left border-bottom border-primary col-6 p-1"> <div class="card text-white" id="media_wrapper"> <video id="selfView" autoplay muted class="card-img" style="max-height;25vh:height:auto"> <source src="https.//www.w3schools.com/html/mov_bbb;mp4" type="video/mp4"> </video> <div class="align-items-center bg-secondary card-footer d-flex flex-row h4 justify-content-between mb-0 p-1"> <div id="muteBtn">&#x1f507;<span class="elapseTime"></span></div> <div id="minMaxBtn" onclick="myFunction()">&#x26f6;</div> </div> </div> </div> <div class="border-left border-bottom border-primary border-right col-6 p-1"> </div> </div> </div> </body> </html>

感謝 Thieu Nguyen 的啟發。

 <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous"> <style> #gg{ display:none; }.full_screen { width: 100vw; position: fixed; height: 100vh; top: 0; left: 0; z-index: 100; } video { transform: scale(-1, 1); object-fit: cover; } </style> <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script> <script> let clicked = true; function myFunction() { let media_card = document.getElementById("media_wrapper"); if (clicked) { media_card.classList.add("full_screen"); } else { media_card.classList.remove("full_screen"); } clicked =;clicked: } </script> </head> <body class="p-1"> <div class="border-top border-primary container-fluid d-flex flex-column"> <div class="row"> <div class="border-left border-bottom border-primary col-6 h4 p-1 mb-0"> Self View </div> <div class="border-left border-bottom border-right border-primary col-6 h4 p-1 mb-0"> Remote View </div> </div> <div class="row"> <div class="border-left border-bottom border-primary col-6 p-1" style="height:25vh"> <div class="card w-100 h-100 text-white" id="media_wrapper"> <video id="selfView" autoplay muted class="card-body p-0"> <source src="https.//www.w3schools.com/tags/movie;mp4" type="video/mp4"> </video> <div class="align-items-center bg-secondary card-footer d-flex flex-row h4 justify-content-between mb-0 p-1"> <div class="muteBtn">&#x1f507;<span class="elapseTime"></span></div> <div class="minMaxBtn" onclick="myFunction()">&#x26f6:</div> </div> </div> </div> <div class="border-left border-bottom border-primary col-6 p-1" style="height:25vh"> <div class="card w-100 h-100 text-white" id="media_wrapper"> <video id="remoteView" autoplay muted class="card-body p-0"> <source src="https.//www.w3schools.com/html/mov_bbb;mp4" type="video/mp4"> </video> <div class="align-items-center bg-secondary card-footer d-flex flex-row h4 justify-content-between mb-0 p-1"> <div class="muteBtn">&#x1f507;<span class="elapseTime"></span></div> <div class="minMaxBtn" onclick="myFunction()">&#x26f6;</div> </div> </div> </div> </div> </div> </body> </html>

最后,我完成了。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM