I have a very simple page in which have 2 columns. video and content i need to do width and height responsive something like image-fluid.
My code
<div class="container">
<div class="row">
<div class="col-lg-8 col-md-6">
<div>
<video muted="" autoplay="" loop=""
src="https://storage.googleapis.com/cms-storage-bucket/029113ae2cbbcf9493fe.mp4" type="video/mp4"
width="950">
<img src="https://storage.googleapis.com/cms-storage-bucket/a667e994fc2f3e85de36.png" alt="Fast">
</video>
</div>
</div>
<div class="col-lg-4 col-md-6 align-self-center" >
<h3>Fast</h3>
<p>Flutter code compiles to ARM or Intel machine code as well as JavaScript, for fast performance on any device.
</p>
</div>
</div>
</div>
Like this
.video_div{
margin-left: -210px;
}
#media (max-width:1199px){
.video_div{
margin-left: -270px;
}
}
<div class="container">
<div class="row">
<div class="col-lg-7 col-md-12">
<div class="video_div">
<video muted="" autoplay="" loop=""
src="https://storage.googleapis.com/cms-storage-bucket/029113ae2cbbcf9493fe.mp4" type="video/mp4"
width="950">
<img src="https://storage.googleapis.com/cms-storage-bucket/a667e994fc2f3e85de36.png" alt="Fast">
</video>
</div>
</div>
<div class="col-lg-5 col-md-12 align-self-center" >
<h3>Fast</h3>
<p>Flutter code compiles to ARM or Intel machine code as well as JavaScript, for fast performance on any device.
</p>
</div>
</div>
</div>
You can Wrap any video tag in a parent element with .embed-responsive and an aspect ratio. The video tag can be given a .embed-responsive-item class as well
<div class="embed-responsive embed-responsive-21by9">
<video class="embed-responsive-item" muted="" autoplay="" loop="" src="https://storage.googleapis.com/cms-storage-bucket/029113ae2cbbcf9493fe.mp4" type="video/mp4" width="950">
<img src="https://storage.googleapis.com/cms-storage-bucket/a667e994fc2f3e85de36.png" alt="Fast /">
</video>
</div>
Official Bootstrap Docs - embed
If you are using Bootstrap 5, you can use the ratio helper :
Use the ratio helper to manage the aspect ratios of external content like
<iframe>s, <embed>s, <video>s, and <object>s. These helpers also can
be used on any standard HTML child element (e.g., a or ).
Styles are applied from the parent .ratio class directly to the child.
source : https://getbootstrap.com/docs/5.0/helpers/ratio/
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" />
<div class="ratio ratio-16x9">
<iframe src="https://www.youtube.com/embed/zpOULjyy-n8?rel=0" title="YouTube video" allowfullscreen></iframe>
</div>
Related
I'm trying to activate a video background. However, I can't get it to play.
<section class="home-section home-full-height bg-dark-30" id="home" data-background="assets/images/section-5.jpg">
<div class="video-player" data-property="{videoURL:'https://youtu.be/x4JSQ7hQCec', containment:'.home-section', startAt:18, mute:false, autoPlay:true, loop:true, opacity:1, showControls:false, showYTLogo:false, vol:25}></div>
<div class="video-controls-box">
<div class="container">
<div class="video-controls"><a class="fa fa-volume-up" id="video-volume" href="#"> </a><a class="fa fa-pause" id="video-play" href="#"> </a></div>
</div>
</div>
I have attempted to modify / remove:
<section class="home-section home-full-height bg-dark-30" id="home" data-background="assets/images/section-5.jpg">
It does nothing.
You can display video with iframe as below
<div class="embed-responsive embed-responsive-16by9">
<iframe class="embed-responsive-item" src="https://youtu.be/x4JSQ7hQCec?rel=0" allowfullscreen></iframe>
</div>
Or use video tag as below
<video class="video-fluid z-depth-1" autoplay loop controls muted>
<source src="https://youtu.be/x4JSQ7hQCec" type="video/mp4" />
</video>
I would like to remove the black borders from a video and keep it responsive. I'm using Bootstrap 4.5. I would also like to keep the panoramic resolution of my video, 1920x764. I am almost sure that the problem has to do with the resolution. Should I then edit the bootstrap .css files?
<body>
<!-- Video -->
<!-- XLG/LG - 21:9 aspect ratio -->
<div class="d-none d-lg-block embed-responsive embed-responsive-21by9 cab-video">
<video class="embed-responsive-item">
<source src="video.mp4">
</video>
</div>
<!-- MD - 16:9 aspect ratio -->
<div class="d-none d-md-block d-lg-none embed-responsive embed-responsive-16by9 cab-video">
<video class="embed-responsive-item">
<source src="video.mp4">
</video>
</div>
<!-- SM - 4:3 aspect ratio -->
<div class="d-none d-sm-block d-md-none embed-responsive embed-responsive-4by3 cab-video">
<video class="embed-responsive-item">
<source src="video.mp4">
</video>
</div>
<!-- XSM - 1:1 aspect ratio -->
<div class="d-block d-sm-none embed-responsive embed-responsive-1by1 cab-video">
<video class="embed-responsive-item">
<source src="video.mp4">
</video>
</div>
<!-- Video -->
<!-- Javascript files -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<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>
</body>
Do you have any idea how i can solve it? Thank you!
As we can see, Bootstrap 4 have a list of embed aspect ratios. The proportions of .embed-responsive-21by9 from this list determines in BS CSS this way:
.embed-responsive-21by9::before {
padding-top: 42.857143%;
}
Looks like your resolution is not quite standard. Let's add a new class to your CSS (or to Bootstrap). Lets say it will be .embed-responsive-19by7. 1920=100%, 764=39.7916% (using proportion 764 * 100 / 1920 = 36.79166). So your additional CSS is
.embed-responsive-19by7::before {
padding-top: 39.7916%;
}
Now your video will be
<!-- panoramic - 19:7 aspect ratio -->
<div class="d-none d-lg-block embed-responsive embed-responsive-19by7 cab-video">
<video class="embed-responsive-item">
<source src="video.mp4">
</video>
</div>
An embedded video will not size to the container div. I've edited the CSS and finally got the poster image to scale correctly, but now the video has cropped on left and right sides by about 50px respectively.
Am I missing a container for the video in the HTML5? Could you please take a look to check my markup and styling?
.blog-side {
position: relative;
}
.wrapper {
margin: 0 auto;
}
.videowrapper {
width: 100%;
height: auto;
text-align: center;
overflow: hidden;
position: relative;
}
<section class="blog-side sp-seven blog-style-one standard-post video-post">
<div class="container">
<div class="row">
<div class="col-md-9 col-sm-12 col-xs-12 content-side">
<div class="blog-details-content">
<div class="wrapper">
<div class="videowrapper">
<div class="embed-responsive embed-responsive-16by9">
<video class="embed-responsive-item" controls poster="images/news/orphan.png">
<source src="video/video1.webm" type="video/webm">
</video>
</div>
</div>
</div>
Many examples and instruction that I'm finding on google don't seem to work. I'm trying to keep the code clean.
Aspect Ratio
In the following demo any tag with non-Bootstrap classes was removed (it's a variable we can do without ATM. The Bootstrap looks good, There's two possible issues:
It could one or more of the non-Bootstrap classes.
or
The dimensions of your video isn't 16:9 ex. 640x360px, 1024x576, etc. The Bootstrap class .embed-responsive-16by9 requires that your video have an aspect ratio of 16:9.
Demo
The video in this demo is 320x240px an aspect ratio of 4:3 and the video tag has the class .embed-responsive-4by3
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.2.1/css/bootstrap.min.css" rel="stylesheet">
<main class="container">
<section class="row">
<section class="col-md-9 col-sm-12 col-xs-12">
<figure class="embed-responsive embed-responsive-4by3">
<video class="embed-responsive-item" controls>
<source src="http://shapeshed.com/examples/HTML5-video-element/video/320x240.ogg" type="video/ogg">
</video>
</figure>
</section>
</section>
</main>
So here's the thing I am trying to do.
I have a video/gif which I want to put on my bootstrap site. I've also got a **p** tag which I want to show over the video and a tint screen so that my paragraph is visible.
<div id="headerwrap">
<div class="col-lg-12">
<video id="background" autoplay="" loop="" muted="" poster="http://i.imgur.com/TFjSLGK.png">
<source src="http://sendvid.com/wdn96a4c" type="video/mp4">
</video>
<div class="container">
<div class="row">
<div class="tint">
</div>
<div class="col-lg-8 col-lg-offset-2">
<h1>Test</h1>
<h2>Make what people love.<br>
</h2>
<h2>This is testing the gif</h2><br><br>Learn More
</div>
</div>
</div>
</div>
</div>
I also have got a screenshot of the video which will be initially present while the video loads and once video starts playing it goes below the video.
Here's the fiddle for the same.
PS: For some reason, the video isn't loading.
I have been trying to embed a video into bootstrap website.
But when I do, it takes up the whole width and height of the screen. I want it to be 560px x 315px on desktops and it should be responsive when the desktop size goes below 560px.
I have used:
<div class="container-fluid">
<div class="embed-responsive embed-responsive-16by9 div_style">
<iframe class="embed-responsive-item" src="http://www.youtube.com/embed/XGSy3_Czz8k" width="560" height="315" frameborder="0" allowfullscreen></iframe>
</div>
</div>
When I try to customize div tag by adding div_style class max-width: 560px; and max-height:315px;, It changes video width to 560px but the height takes up the whole page height.
You missed to add col-xs-12 col-sm-6 col-md-4 col-lg-2. Something like this.
<div class="container-fluid">
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-2 padding-zero embed-responsive embed-responsive-16by9">
<div id="foxnews">
<iframe class="embed-responsive-item" src="https://www.youtube.com/embed/KFGbHBbXG_g?modestbranding=1&autohide=1&showinfo=0&rel=0" allowfullscreen="true"></iframe>
</div>
</div>
</div>
The bootstrap embed-responsive classes use padding-bottom to set the "height" of the element.
You can change this property along with width within a media query for your desired effect.
#media all and ( min-width: 560px ) {
.div_style {
width:560px;
padding-bottom:315px !important;
}
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<div class="container-fluid">
<div class="embed-responsive embed-responsive-16by9 div_style">
<iframe class="embed-responsive-item" src="http://www.youtube.com/embed/XGSy3_Czz8k" width="560" height="315" frameborder="0" allowfullscreen></iframe>
</div>
</div>
<div className="overlay"></div>
<div className='container-fluid vids col-md'>
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-2 padding-zero embed-responsive embed-responsive-16by9">
<video playsInline="playsinline" autoPlay="autoplay" muted="muted" loop="loop">
<source src="videos/design.mp4" type="video/mp4"/>
</video>
</div>