Implementing Background Video in Bootstrap 5 for a Stunning Hero Section

I have a unique template design that I am working on:

https://i.sstatic.net/lLleK.png

My goal is to replace the current background image with a video. Here is my attempt by adding a <video> tag:

<!-- ======= 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>
      <a href="#about" class="btn-get-Started scrollto">Get Started</a>
    </div>
  </section><!-- End Hero -->

Unfortunately, the video overlaps the next div as shown here:

https://i.sstatic.net/86DCf.png

I also tried changing the background image source to a video but the video did not load:

#hero {
  width: 100%;
  height: calc(100vh - 110px);
  background: url("https://www.w3schools.com/howto/rain.mp4") top center;
  background-size: cover;
  position: relative;
}

The result was unsatisfactory:

https://i.sstatic.net/HrsCu.png

Can anyone provide guidance on how to properly display the background video and ensure that the welcome message div appears over it rather than beside it?


UPDATE:

New code implementation:

<!-- ======= 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>
            <a href="#about" class="btn-get-started scrollto">Get Started</a>
        </div>
    </section><!-- End Hero -->

Updated result:

https://i.sstatic.net/t0kwj.png

Answer №1

It seems that utilizing position:absolute would be the solution in this case...

<!-- ======= Welcome Section ======= -->
    <section id="welcome" class="d-flex align-items-center">
        <video autoplay muted loop id="myVideo">
            <source src="https://www.example.com/video.mp4" type="video/mp4">
        </video>
        <div class="container position-absolute" data-aos="fade-up" data-aos-delay="500">
            <h1>Welcome to Our World</h1>
            <h2>We are a creative team crafting stunning websites using Bootstrap</h2>
            <a href="#about" class="btn-get-started scrollto">Let's Begin</a>
        </div>
    </section><!-- End Welcome -->

Demo

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for Displaying JSON Data on an HTML Page

How can I display JSON data in an HTML web page and group names from the JSON Data only? Here is the URL for the data: http://www.celeritas-solutions.com/pah_brd_v1/productivo/getGroups.php?organizationCode=att&userId1 I have searched online and fo ...

The hover feature in the plugin is stuck in an infinite loop

I'm currently working on a plugin that will change the background color of an image to semi-transparent black when it's hovered over. To achieve this effect, I've added a overlay class tag above the image. Since each image may have different ...

Exploring the world of web scraping using Scrapy, Python, and a JavaScript-based website all in one

Hello, I am attempting to scrape the website using the following script: script.py import scrapy from scrapy.crawler import CrawlerProcess from threading import Thread class CourtSpider(scrapy.Spider): name = 'full_page' allowed_domai ...

Display elements that are positioned absolutely within a container with scrolling overflow

My modal contains a scrollable list with many items that have absolute positioned elements causing overflow within the modal. How can I ensure that the absolute positioned elements are visible in this scenario? .modal { width: 300px; border: 1px ...

Issue with the camera functionality in phonegap 3.3.0 API on IOS platform

I am currently in the process of developing an application for iPad that will allow users to capture and store photos. I have encountered some difficulties while using the PhoneGap camera API library, as my code is not generating any errors which makes i ...

The JQuery code restricts the use of multiple buttons within a single instance

UPDATE I am facing an issue where I am trying to add the same set of buttons inside multiple divs, however, it seems that the button set only appears in one div at a time. I want the button set to show up in every location where I place it. Here is the co ...

Creating a Redirect Form that Directs Users to a Specific Page Depending on Input Data

Apologies if this is a basic issue, but I'm struggling to figure it out. I am trying to create a form field on a webpage that will redirect users to a specific page based on the data they input. For example, if someone types in "dave" and submits the ...

When incorporating the http-proxy-middleware in an express app, be aware that form parameters may not be transmitted

Describing my architecture for a specific problem can be complex and abstract. Currently, I am delving into the world of microservices with nodejs, express framework, handlebars for UI, and http-proxy-middleware to establish a network. In this setup, each ...

Tips for inputting a password using Selenium webdriver when the password style is set to display:none

Currently, I am facing an issue with logging in to a page that has both a login and password field (betmarathon[d.o.t]com) using Selenium Webdriver. While Selenium is able to enter the login correctly, I am encountering difficulties when it comes to enteri ...

Styling an unordered list with CSS in HTML is a powerful

I am working with an unordered list where each list element contains two spans: span A and span B. My goal is to style these elements so that they are displayed horizontally on the screen, with span A above span B in each set. Example: spanAItem1 sp ...

What's causing the HTML body to be fixed at the top of the viewport?

Currently, I am in the process of developing a commandline tool to quickly generate an HTML Bootstrap starter template for my personal use. The main issue I am facing is with the index page, where a basic navigation bar should be displayed at the top, and ...

JavaScript does not display checkbox values

I am currently testing whether checkbox values appear on the client side. When I execute the code, the alert is not showing anything. I would greatly appreciate any assistance, thank you. <div> <label name="finishing"class=" ...

The aesthetic of react-bootstrap and material ui aesthetics is distinctive and visually appealing

As I develop my web application, I have incorporated react-bootstrap for its React components based on Bootstrap. However, wanting to give my project a customized look inspired by Material design, I came across bootstrap-material-design. I am curious if I ...

What steps can I take to avoid the onBlur event from triggering?

I am in the process of developing an input field with a dropdown feature for suggestions. Currently, I have set up an input element that triggers onBlur event to remove the ul element when clicked outside. However, I noticed that clicking on the ul element ...

Employ the $scope.go() method within a function written in JavaScript

I am working with some HTML code that looks like this <body ng-app="app" ng-controller="IndexCtrl" id="indexBody"> <h1>test</h1> </body> Next, in a JavaScript function, I retrieve the scope like so function myFx() { ...

Can you point me in the right direction for declaring the ImageObject format in Angular?

To create an Image Slider similar to the one shown here, I need to load images from a source. However, I'm unsure about where exactly in the file (possibly in the component.ts?) I should declare them: imageObject: Array<object> = [{ ...

The collapse button in Bootstrap 3.3 and jQuery 1.1 appears to be visible but unresponsive when clicked

This code isn't functioning properly as it displays the three horizontal bar button, but nothing happens when clicked. bootstrap-3.3 jquery-1.1 Toggle navigation CopyHere <div class="collap ...

Avoiding page shifting/browser resizing when the android keyboard appears

This question pertains to an HTML5/Javascript WebApp, rather than a native Android app. Is there a way to stop the browser/the DOM from adjusting my responsive content (which primarily uses vw/vh for sizes) when the android soft keyboard is activated? The ...

Object C UIWebView adapting to HTML

How can I get a responsive HTML page to display correctly in a UIWebView in Xcode? The page adjusts properly in other iPhone browsers, but not in the UIWebView. I would prefer not to use PhoneGap for this. Any suggestions for making the HTML responsive i ...

Formcontrol is not functioning properly with invalid input

I am attempting to style an input field with a FormControl using the :invalid pseudo-class. Here is my code snippet: scss input:invalid { background-color: red; } html <input type="text" [formControl]="NameCtrl"> Unfortunate ...