English 中文(简体)
boot custom custom custom 不接受最大载荷
原标题:bootstrap custom-sized video embed not accepting max-height

I have embedded a tall video in this bootstrap carousel.

幻灯2的电话录像是“没有boot子的陷阱标准大小”。 4x5

舱面=“盒式”

/* Custom aspect ratio for 4x5 video / .embed-responsive-4by5 { padding-bottom: 125%; / 5/4 aspect ratio */ }

the video scaling works great, but it won’t accept a MAX HEIGHT e.g. 900px, or 90vh

  • i’ve tried adding max height to the iframe, and all the divs around it.
  • Nothing seems to work, it won t scale to a set max height and stay inside the container.

任何想法?

最新法典如下:

  • see the second slide with the phone video... it s too tall without being able to set a max height

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Multiple Responsive Slideshows</title>
  <!-- Bootstrap CSS -->
  <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
  <style>
    body {
      background-color: violet;
      margin: 10px; /* Reset margin to 0 */
      padding: 0; /* Reset padding to 0 */
    }

    .container {
      background-color: green;
      margin-bottom: 50px;
      padding: 10px;
      display: flex;
      justify-content: center;
      align-items: center; }

    .slideshow-container {
      position: relative;
      width: 100%;
      margin: auto;
      overflow: hidden;
      background-color: #b9dbe5;
      display: flex; /* Use flexbox layout */
      justify-content: center; /* Center items horizontally */
      align-items: center; /* Center items vertically */
    }

    .carousel-item {
      text-align: center; /* Center images horizontally */
    }

    .slideshow-container img, 
    .slideshow-container iframe {
      max-width: 100%;
      max-height: 100%;
      object-fit: contain;
    }

    /* Show arrows only on hover */
    .slideshow-container:hover .prev, 
    .slideshow-container:hover .next {
      display: block;
    }

    .prev, .next {
      display: none;
      cursor: default; /* Change cursor to default */
      z-index: 1000;
      color: silver;
      font-weight: bold;
      font-size: 30px;
      position: absolute;
      top: 50%;
      transform: translateY(-50%);
      width: auto;
      padding: 16px;
      border-radius: 0 3px 3px 0;
      user-select: none;
      text-decoration: none; /* Remove underline */
    }

    .prev:hover, .next:hover {
      text-decoration: none; /* Remove underline */
      color: silver; /* Change color on hover */
    }

    .prev {
      left: 0;
    }

    .next {
      right: 0;
      border-radius: 3px 0 0 3px;
    }

    .prev.disabled, .next.disabled {
      pointer-events: none;
      opacity: 0.5;
    }
      
   /* //////// Media query ////////  */
    @media screen and (max-width: 650px) {
    body {
        background-color: goldenrod;
        
 /* Videos and can be full width on mobile */
      }
         .carousel-item img {
    width: 100% !important;
    padding: 0 !important;
  }

      .carousel-item iframe {
        width: 100% !important;
        height: 100% !important;
        padding: 0 !important;
      }
        .vidbox {
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        max-height: 100% !important;
      }
    }

 /* Custom aspect ratio for 4x5 video */
    .embed-responsive-4by5 {
      padding-bottom: 125%; /* 5/4 aspect ratio */
    }
      
  </style>
</head>
<body>

<div class="container" style="max-width: 1000px">
  <div id="myCarousel1" class="slideshow-container carousel slide" data-ride="carousel" data-interval="false">
      
    <!-- Image Slides -->
    <div class="carousel-inner">
        
      <div class="carousel-item active">
        <img src="https://source.unsplash.com/random/1200x600/?kitten" style="padding: 30px;">   
        </div>
        
        
                  <!-- Video Slide -->
      <div class="carousel-item">
          <div style="max-height: 700px">
    <div id="phone" 舱面=“盒式” style="max-height: 700px; margin: auto; text-align: center;">
  <iframe src="https://player.vimeo.com/video/912417077?badge=0&amp;autopause=0&amp;player_id=0&amp;app_id=58479" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen style="padding: 0px"></iframe>
      </div>
     </div>
    </div>
        
    
              <!-- Video Slide -->
      <div class="carousel-item">
    <div id="nochill" class="vidbox embed-responsive embed-responsive-16by9" style="max-width: 800px; margin: auto; text-align: center;">
  <iframe src="https://player.vimeo.com/video/143374377?h=760ef66606&title=0&byline=0&portrait=0" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen style="padding: 0px;"></iframe>
      </div>    
    </div>
        
        
   <!-- Navigation Arrows -->
   <!-- Navigation Arrows -->
    <a class="prev" href="#myCarousel1" data-slide="prev">&#10094;</a>
    <a class="next" href="#myCarousel1" data-slide="next">&#10095;</a>
  </div>
</div>


<!-- Bootstrap JS -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>

<!-- Navigation Click anywhere to navigate -->
<script>
  $(document).ready(function(){
    $( .carousel-inner ).on( click , function(e) {
      if (e.pageX < $(this).width() / 2) {
        $(this).closest( .carousel ).carousel( prev );
      } else {
        $(this).closest( .carousel ).carousel( next );
      }
    });
  });
</script>
    
    
    
</body>
</html>
问题回答

Bootstrap v4 uses a legacy method to control aspect ratio, known as "the top-padding hack".

简言之,将百分之一的垂直胎盘应用于一个块级元素,则根据<代码>width计算,而不是以<代码>h 8,为基础。 在CSS中加入aspect-ratio之前,这是控制aspect-ratio的一个绝佳途径,其中包括几个方面。 并且是交叉浏览器。

So what appears to be the height of the wrapper, is actually the top-padding. The content height is 0 (and it has to stay that way, for maintaining the aspect-ratio). But, because of this, max-height has no effect.

但是,你可以通过控制<条码>、最大宽限/代码>来控制<条码>,因为你已经知道<条码>。

简言之:

  /* max-height: 600px; */
  max-width: 480px;

在更仔细地检查了安装的缺损装置的侧面,它像有办法订立<条码>最大载荷/代码>。 适用于使用顶层dding子的元素,添加了<条码>:在之前,添加了同样的百分垂直胎。 阁下:

.embed-responsive-4by5::before {
  padding-top: 125%;
}




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

Drop down background url in Safari Issue

selectBox.selectCSS { background: url(/Images/replacementSelectBackground.png) top left no-repeat height:auto; } I have an issue in Safari only where the image is not rendering on top ...

CSS specific for Safari

How do you target specifically safari in css with styles?

Aligning textarea in a form

Ive used the following css code to align my form elements: form { position:relative; } form input { position:absolute; left:11em; } However, the textarea element is not aligned correctly with the ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

CSS problem with page footer

I have defined my page footer in the css file as: #footer { position: absolute; height: 50px; text-align: center; background: #66CCCC; bottom: 0px; left: 0px; width: 100%; height: ...

热门标签