Bootstrap 5: How to add Background Video as Hero - html

I have a template looks like this:
Now I want to replace the Background image with a Background video. So I tried adding this <video> to the section:
<!-- ======= Hero Section ======= -->
<section id="hero" class="d-flex align-items-center">
<video autoplay muted loop id="myVideo">
<source src="https://www.w3schools.com/howto/rain.mp4" type="video/mp4">
</video>
<div class="container position-relative" data-aos="fade-up" data-aos-delay="500">
<h1>Welcome to Day</h1>
<h2>We are team of talented designers making websites with Bootstrap</h2>
Get Started
</div>
</section><!-- End Hero -->
But as you can see the video collapses the next div like this:
I also tried changing background image source to video but didn't load the video:
#hero {
width: 100%;
height: calc(100vh - 110px);
background: url("https://www.w3schools.com/howto/rain.mp4") top center;
background-size: cover;
position: relative;
}
Result:
So how can I load the background video properly so that next div which is the welcome message will be over that and not next to it?
UPDATE:
Code:
<!-- ======= Hero Section ======= -->
<section id="hero" class="d-flex align-items-center">
<video autoplay muted loop id="myVideo">
<source src="https://www.w3schools.com/howto/rain.mp4" type="video/mp4">
</video>
<div class="container position-absolute" data-aos="fade-up" data-aos-delay="500">
<h1>Welcome to Day</h1>
<h2>We are team of talented designers making websites with Bootstrap</h2>
Get Started
</div>
</section><!-- End Hero -->
Result:

Looks like you just need to use position:absolute instead...
<!-- ======= Hero Section ======= -->
<section id="hero" class="d-flex align-items-center">
<video autoplay muted loop id="myVideo">
<source src="https://www.w3schools.com/howto/rain.mp4" type="video/mp4">
</video>
<div class="container position-absolute" data-aos="fade-up" data-aos-delay="500">
<h1>Welcome to Day</h1>
<h2>We are team of talented designers making websites with Bootstrap</h2>
Get Started
</div>
</section><!-- End Hero -->
Demo

Related

Html video tag not support ios/iphone

hi i created responsive website, for android it is working fine but for ios/iphone it does not showing me the videos and thumbnail till i click play button what could be the issue,
here is my some html code and iphone screenshots
here is the iphone screenshot
<body>
<div class="container">
<div class="row">
<div id="ls-video">
<ol>
<li *ngFor="let animalvideo of Animalvideos">
<video class="mycheck" (click)="videoshow(animalvideo)" preload="metadata" controls [src]="'http://54.172.101.222:8080/'+animalvideo.filePath" type="video/mp4" playsinline loop muted ></video>
</li>
</ol>
</div>
<div id="video-play">
<video id="video-side" preload="metadata" [src]="'http://54.172.101.222:8080/'+selectedVD" type="video/mp4" alta="show" controls playsinline loop muted ></video>
</div>
</div>
</div>

Bootstrap 5 how to make video size responsive

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>

Remove the black borders from a responsive video Bootstrap 4

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>

video not sizing to container 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>

Text over a video and a tinted screen in html

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.