Maximizing Screen Size for Videos on Internet Explorer: A Step-by-Step Guide

How can I make the video background fit properly on all browsers, including IE, without zooming it? Here is my website link:

The CSS property object-fit: cover works for most browsers, but unfortunately IE does not support this property.

I would appreciate any insights or suggestions regarding this issue. Thank you!

Answer №1

Employing a clever mix of vw/vh units, utilizing position, and incorporating transform

.bg {
  position: absolute;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  display: flex;
  justify-content: center;
  z-index: -1;
  top: 0;
  left: 0;
}

video {
  width: 100vw;
  height: 100vh;
  min-height: calc(100vw * 9 / 16);
  min-width: calc(100vh * 16 / 9);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translateX(-50%) translateY(-50%);
}

body {
  margin: 0;
  font-family: sans-serif;
  font-size: 62.5%;
}

.foreground {
  margin: 30px auto;
  width: 60%;
  background-color: rgba(255, 255, 255, 0.3);
  padding: 20px;
}

h1 {
  font-size: 3rem;
  font-weight: 700;
  margin: 0;
}
<div class="bg">
  <video src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3c5e555b115e495f57115e49525245110d0c040c4c7c0c120c120a">[email protected]</a>/video.mp4" autoplay muted loop></video>
</div>

<div class="foreground">
  <h1>Background Video Cover</h1>
</div>

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

Executing a simulated onClick event in jQuery

Attempting to create a simulated onclick event on a drop-down menu has proved challenging for me. An IE object is being used to navigate to a page, where I need to modify a dropdown menu that contains an onchange event: $('select[name="blah"]') ...

Best practices for locating unique symbols within a string and organizing them into an array using JavaScript

Here is an example string: "/city=<A>/state=<B>/sub_div=<C>/type=pos/div=<D>/cli_name=Cstate<E>/<F>/<G>" The characters A, B, C, and so on are variables, and their count is not fixed. Can you determine how many ...

Transform a group of objects in Typescript into a new object with a modified structure

Struggling to figure out how to modify the return value of reduce without resorting to clunky type assertions. Take this snippet for example: const list: Array<Record<string, string | number>> = [ { resourceName: "a", usage: ...

Using CSS to position elements absolutely while also adjusting the width of the div

In one section of my website, I have a specific div structure. This structure consists of two divs stacked on top of each other. The first div is divided into two parts: one part with a width of 63% and another part with a button. Beneath the first div, t ...

Using Angular to Apply a Custom Validation Condition on a FormGroup Nested Within Another FormGroup

I am facing an issue with my form validation logic. I have a set of checkboxes that need to be validated only when a specific value is selected from a dropdown. The current validator checks the checkboxes regardless of the dropdown value. Here's the c ...

Ways to modify the background shade of a bootstrap column

I am looking to customize the background color of a single column within a bootstrap row, along with applying padding to the row. Please refer to the screenshot provided below for clarification. https://i.sstatic.net/S9Lfx.png <div class="cont ...

Mouseover function not triggering until clicked on in Google Chrome

I'm attempting to execute a function when the cursor hovers over a list item as shown below: <div id="vue-app"> <ul> <li v-for="item in items" @mouseover="removeItem(item)">{{item}}</li> </ul> </div> ...

"Running 'npm run build' in Vuejs seems to have a mind of its own, acting

Recently, I completed a project and uploaded it to Github. The issue arises when I attempt to clone it to my live server - only about 1 out of 10 times does everything function correctly after running npm run build. My setup consists of Ubuntu 16 with ngin ...

Create a dynamic div element using Jquery that is generated based on text input

I am attempting to dynamically insert a div based on the text within the parent container. My HTML structure is as follows: <div class="listing_detail col-md-4"><strong>Living Room:</strong> Yes</div> <div class="listing_detail ...

Encountering error #426 in NextJs when the app is loaded for the first time in a new browser, but only in a

Encountering a strange error exclusively in production, particularly when loading the site for the first time on a new browser or after clearing all caches. The website is built using nextjs 13.2.3 and hosted on Vercel. Refer to the screenshot below: http ...

Forgetting your password with React JS

On my login page, there is a button labeled "Forget my password". When I click on this button, I want to be taken directly to the correct page for resetting my password. Currently, when I click on "forget my password", it displays beneath the login sectio ...

What is the best way to modify the color of a button within an AngularJS function by utilizing the same button?

Currently, I have a function assigned to the ng-click event on a button in order to filter a list. My goal is to change the color of the button once it has been clicked and the filtered list is displayed. I am looking for a way to achieve this within the ...

Sliding a division using Jquery from the edges of the browser's window

<script> $(function(){ $('#right_image1').hide().delay('10000').fadeIn('5000').animate({right: '0'}, 5000); $('#left_image1').hide().delay('10000').fadeIn('5000').a ...

When coding on Github pages, the behavior of code blocks can vary depending on whether

I am interested in obtaining the offline version, which can be seen here: https://i.sstatic.net/NKFSQ.jpg On the other hand, the online version has a different appearance: https://i.sstatic.net/133gH.jpg If you want to view the incorrect version, click ...

Obtaining a return value from a function in Angular

After just starting to work with Angular, I am attempting to extract a value from a button displayed in the HTML using a function. `<button class="btn" id="btn-gold" (click)="value(9)" name="mybutton" value="9">` 9 I have also inclu ...

Struggling with serving static content on NodeJS using Express.js

I set up a basic NodeJS and Express server on my development machine running Windows 10. var express = require('express'); var app = express(); app.use(express.static('app')); app.use('/bower_components', express.static(&apo ...

Updating the color scheme of the selected nav-item and showcasing the corresponding page in relation to the navbar selection

I have been trying various methods, but I am unable to change the background color of an active navigation item and also display the corresponding page. Important: The jQuery code below successfully changes the background color of the navbar list item. Ho ...

Using external components, such as antd, with Style JSX in a NextJS project is not functional

I am exploring the use of Style JSX within a Next JS application to customize AntD components, with a focus on customizing the appearance of the sidebar (specifically using Style JSX to modify AntD's Sider component). Below is a snippet of the code I ...

Optimizing CSS for printing by eliminating unnecessary white space with media queries

Appreciate your assistance! I'm currently working on a solution to print a specific div using CSS Media queries. When the user clicks on print, I want to hide all other elements except for the body div they chose. However, I'm facing an issue whe ...

Implementing a sticky header for tables using Bootstrap

I'm experiencing a conflict because the header remains fixed only when I include the table-responsive class in my code. However, I also need the table to have overflow. Can anyone provide assistance with this issue? Using the table-responsive class ...