Bootstrap carousel with responsive HTML5 videos?

I'm trying to make a carousel with a video. It works great with images, the image reacts even in mobile mode. But with videos, the width is sensitive, but not the height. Basically, I would like to reach the same compromise with the carousel, but with the video. I have tried many tricks on the net, but no one does it. My video is 1024 / 552px

I tried my best on the violin. You can see if you downloaded the violin with a small width, it retains the same height and does not respond, but the width of the carousel / video (it cuts the video on the sides, though). It does not have the same layout as the image. As you will see, I included the image in the second slide to once again demonstrate my problem.

https://jsfiddle.net/687bsb21/1/

Here is the code:

<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
 <ol class="carousel-indicators">
        <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
  <li data-target="#carousel-example-generic" data-slide-to="1"></li>
      </ol>

      <!-- Wrapper for slides -->
      <div class="carousel-inner" role="listbox">            

        <div class="item active">
             <div align="center">
               <video autoplay loop>
                 <source src="http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4" width="1024" height="552" type="video/mp4">
                 Your browser does not support the video tag.
              </video>
          </div>
             <div class="carousel-caption">
              <h3>hello</h3>
              <p>hello</p>
            </div>
          </div> 
            <div class="item">
          <img src="http://dummyimage.com/1024x552/000/fff" class="img-responsive" alt="asfds">
          <div class="carousel-caption">
              <h3>hello</h3>
              <p>hello.</p>
            </div>
        </div>
          <a class="left carousel-control" href="#carouselHelp" role="button" data-slide="prev">
        <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
        <span class="sr-only">Previous</span>
      </a>
      <a class="right carousel-control" href="#carouselHelp" role="button" data-slide="next">
        <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
        <span class="sr-only">Next</span>
      </a>
</div>

Thanks for the help.

+4
3

css,

video{
width:100%
}
+1

/ :

<video autoplay loop width="1024" height="552">

.

+1

This is the best solution:

<div class="container">
  <video><source src="video.mp4" type="video/mp4"></video>
</div>

.container{
  position: relative;
  width: 100%
}
.container video{
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%,-50%);                            
}
0
source

All Articles