I could use some input on the best way to make a background video fill the screen while incorporating overlay text

Struggling to make the background video fit perfectly on all devices and browsers? While it looks great in Chrome now, I'm still facing some clipping issues with IE Edge. Any experts out there who can offer their validation or suggest improvements?

If you want to take a look at the code, here's the link to the CodePen: https://codepen.io/jslearner1/pen/ydrzZz?editors=1100

*{
  margin:0;
  padding:0;
}

body{
    font-size: 62.5%;
    box-sizing: border-box;
    font-family: 'Lato',sans-serif;
    letter-spacing: 0.5px;
    line-height: 1.7;
    background-color: #fcfcfc;
    
}

.header{
    width: 100%;
    height: 100vh;
    font-size: 2rem;
    color: #fcfcfc;
    position: relative;
    z-index: 99;
    overflow: hidden;

    .overlay{
        position: absolute;
        top:0;
        left: 0;
        width: 100%;
        height: 100vh;
        background-color: rgba(#000000,0.8);
        z-index: 1;

        &__text{
            position: absolute;
            top:50%;
            left: 50%;
            transform: translate(-50%,-50%);
        }

    }

}

.bg_video{
    position: absolute;
    top:0;
    left:0;
    width: 100%;
    height: 100vh;
    object-fit: cover;

    
    
}
    <body>    
    <header class="header">
        
        <div class="overlay">
        <div class="overlay__text">
            <p>Welcome !!!</p>
        </div>
        </div>
      
        <!--  Video Taken from George Park Code pen -->
        <video autoplay muted loop class="bg_video">
            <source src="http://www.georgewpark.com/video/blurred-street.mp4" type="video/mp4">
            <source src="http://www.georgewpark.com/video/blurred-street.mp4" type="video/webm">
                your browser is not supported
        </video>
        

    </header>
    </body>

Answer №1

Having a similar issue as discussed here: Fixing object-fit: cover in IE and Edge browsers

Despite being supported, object-fit seems to be not functioning properly in Edge browser. To address this, consider updating your .bg_video css with the following code snippet:

.bg_video{
    position: absolute;
    top:50%;
    left:50%;
    width: 100%;
    height:auto;
    transform: translate(-50%, -50%);
}

Answer №2

To achieve the desired effect, consider utilizing the object-fit property like so:

.background_video {
   object-fit : cover;
 }

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

What can I do to prevent my HTML/CSS/jQuery menu text from shifting when the submenu is opened?

After encountering numerous inquiries regarding the creation of disappearing and reappearing menus, I successfully devised a solution that functions seamlessly on desktop and tablet devices. My approach involved utilizing the jQuery .toggleClass function w ...

The form transmits the URL parameter rather than executing an update

I'm having trouble with my code and can't seem to figure out why it's behaving this way. When I try to update a recordset, the page reloads upon hitting the submit button and multiple URL parameters appear in the address bar. There are two ...

Superimpose two actionlinks and prioritize the one appearing above

I have implemented a menu similar to http://tympanus.net/Tutorials/SlideDownBoxMenu/. Below this menu, I have placed a webgrid. The issue I am facing is that when I hover over the menu, the slidedownbox with two action links pops up directly over the heade ...

Encountering a problem with serializing forms using jQuery

Currently, I am working on form serialization in order to send the file name to the server. However, I have encountered an issue where the serialization values are empty and I am expecting the file name to be included. Within my form, there is an HTML fil ...

What can be used instead of the html5 output tag?

After creating a webpage with a form that includes several "number" input fields, I utilized the html output tag to showcase the results. However, when viewed in MSIE, although the calculations were successfully done, the output tag failed to display the ...

What is the best way to horizontally center an image in Bootstrap 4 while having a fixed-top navbar and preventing vertical scrollbars?

I am struggling to achieve the desired outcome, which is depicted in this image: https://i.sstatic.net/i6X0j.jpg Specific requirements for this project include: The image must be responsive A fixed-top navbar should remain visible No vertical scrolling ...

VS code is showing the directory listing instead of serving the HTML file

Recently, I attempted to use nodejs to serve the Disp.html file by following a code snippet from a tutorial I found on YouTube. const http = require("http"); const fs = require("fs"); const fileContent = fs.readFileSync("Disp.html& ...

Information disappearing upon returning to a previous screen

Currently, I am developing a web application using AngularJS and HTML. As part of the application, I created a dashboard on the home screen (referred to as Screen A) that displays a list of clients with a summary. When a client is clicked, it navigates t ...

When using HTML5's checkValidity method, it may return a valid result even if

Consider the following scenario: <input pattern="[a-z]"/> If you run the command below without entering any input: document.querySelector('input').checkValidity() You will notice that it actually returns true. This seems counterintuiti ...

Navigating through a PHP table, tracking your progress with a

I have encountered a problem that I need help with. I have been searching the internet for information on how to add a progress bar to my PHP code. Most solutions I found use the style method to display the progress percentage. In the image below, you can ...

Issue with Bootstrap Carousel displaying as a static image instead of a slide

I have worked on creating a Portfolio.js file using the react library with react-bootstrap Carousel.js to build an uncontrolled carousel. However, my code is showing the slides vertically instead of behaving like a typical carousel. You can view my code at ...

Retrieving Dynamic data from an HTML form and saving it in PHP variables

Currently, I am in the process of taking an online aptitude test where 2 random questions are selected from a database and displayed on the webpage for answering. The issue I'm facing is that the values are not being stored correctly in the database. ...

I would appreciate your assistance with the hide button

Is there a way to hide a button after clicking on it? I would greatly appreciate your help! ...

Issues with scaling background videos in HTML5

I'm having trouble making a video scale properly with the browser window while still covering the entire area. Does anyone know why my current approach isn't working? HTML: <div class="bgVideoWrap"> <video id="bgVideo" loop="true" aut ...

When attempting to retrieve the innerHTML of a <div> element within a <Script> tag, the value returned is undefined

Utilizing a masterpage to create a consistent header across all content pages, I encountered an issue on one page. I needed to retrieve the innerHTML of a div element and pass it to an input control on the same page in order to access the updated innerHTML ...

The BBCode seems to be malfunctioning

I created a custom BBCode for my PHP website to display tabbed content on a page. After testing the BBCode on a separate webpage and confirming there are no errors, I am facing an issue where the tabbed content is not showing up on the actual posting page. ...

What is the most effective way to determine which radio button is currently selected in a group with the same name using JQuery?

<form class="responses"> <input type="radio" name="option" value="0">False</input> <input type="radio" name="option" value="1">True</input> </form> Just tested: $('[name="option"]').is(':checked ...

Tips for ensuring compatibility of CSS in IE7 and IE8

Despite using the following styles to dynamically display alternative colors in my HTML code, I am facing compatibility issues with IE7 and IE8. Surprisingly, everything works perfectly fine on IE9 and above. It seems these styles are not supported by IE7 ...

CSS navigation bar (background gradient problem)

I have encountered an issue with my multi-tier navigation menu where tiers below tier 1 are displaying an unexpected block to the left of the options. I suspect this problem is related to the background gradient applied, but I haven't been able to fin ...

Scroll positioning determines the height of an entity

Here's a code snippet I'm working with: HTML: <div id="wrap"> <div id="column"></div> </div> CSS: #wrap { display: block; height: 2000px; width: 400px } #column { display: block; height: 20px; ...