Utilizing a local video file as a video background in HTML and CSS

I've hit a roadblock while attempting to set a video on my computer as the background. The video file is named "runbg.avi" and it resides in the same folder as my HTML and CSS files.

After scouring through numerous websites, I encountered a couple of potential solutions:

One suggestion was to use file:// instead of http:// when referencing videos stored locally.

Another advice mentioned that pointing to videos hosted online works fine but having them play from local sources can be tricky.

This is what I have worked on so far:

/* BACKGROUND */
video#vid {
    position: fixed; 
    right: 0; 
    bottom: 0;
    min-width: 100%; 
    min-height: 100%;
    width: auto; 
    height: auto; 
    z-index: -100;
    background-size: cover;
    margin: 0 auto;
}
<!DOCTYPE html>
<head>
<title>Seb's Fitness</title;

<link rel = "stylesheet"
      type = "text/css"
      href = "css.css" />

<video autoplay loop poster="" id="vid">
    <source src="file://runbg.avi" type="video/avi">
</video>

Answer №1

<video autoplay loop poster="" id="vid">
    <source src="/background/runbg.avi" type="video/avi">
 </video>

/runbg.avi points to the runbg.avi file located in the root folder (/) within the background folder.

For more information on the difference between relative and absolute paths, visit this link.

Answer №2

UPDATE: AVI video types are not compatible with the HTML5 video tag.

To work around this issue, you can utilize an online video converter tool to switch to a supported video format such as MP4, OGG, or WEBM.

Is the .avi format supported by HTML5 <video> playback?

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

A guide to mastering the art of descending using three distinct class types

My script is functioning properly for a single class, but it fails to work for multiple classes with the same purpose. I attempted to transfer from div (#panel) to class (.panel) as I am using several classes. However, this adjustment did not resolve the i ...

Guide on utilizing ffmpeg in conjunction with PHP for file compression and uploading

Hello everyone, I have successfully installed ffmpeg on my local computer and now I'm looking to learn how to use it for uploading files via PHP to the server. My goal is to convert all user-uploaded files to SWF format. Additionally, I've increa ...

Position the personalized radio button to be in line with the first choice text

I frequently update this section with a new Jsfidle link to demonstrate the issue when the max-width is set to 300px. For responsive design, adding the "span" tag before radio buttons helps align input content with custom checkbox backgrounds. To see the ...

Which html parsing tool is capable of processing encoding?

The journey begins -- I have a file saved on my computer that is an HTML page. When I view it in a regular web browser, the correct characters are displayed regardless of the encoding used. Then comes the challenge -- my task is to load the same file, par ...

Webpage Text Animation

This is the visual representation of my webpage: https://i.stack.imgur.com/tYq34.png I am seeking to implement a uniform animation effect for the text "Carlos Qiano" and "Lorem Ipsum", similar to the link below: https://i.stack.imgur.com/XVnBS.jpg Note: ...

Unable to select a checkbox in an ASP.NET Core MVC view

In the process of developing an ASP.NET Core 3.1 MVC application, I am faced with a task to implement a dynamic checkbox menu for selecting fruits and storing the choices in another data source. However, encountering an issue where I'm unable to sele ...

Creating inner borders on a pie chart with HTML and CSS: A step-by-step guide

After putting my coding skills to the test, I successfully crafted a stunning pie chart using only HTML and CSS. https://i.sstatic.net/5xCbl.png Here's the code snippet I tinkered with: HTML - <div class="pie-chart"></div> CS ...

Programme for Server Login

After creating my own server, I attempted to implement a login feature to restrict access to its files. Unfortunately, using Javascript for this task proved to be insecure as usernames and passwords could easily be viewed in the source code: <form name ...

Is it possible for me to utilize a validation function to display error messages within a specific span id tag?

document.getElementById("button1").addEventListener("click", mouseOver1); function mouseOver1(){ document.getElementById("button1").style.color = "red"; } document.getElementById("button2").addEventListener("click", mouseOver); function mous ...

Is there a way to access the origin of an iframe?

I am facing a challenge with an HTML page that includes an iframe. Within the iframe, there are text and buttons that trigger onclick scripts. However, I'm having difficulty retrieving the values of getBoundingClientRect when I specify the ID of the b ...

There was a type error that occurred because the property 'addEventListener' could not be read from an undefined value

Encountering an issue with the JavaScript libraries three.js and OrbitControls.js despite following a tutorial: However, an error is being displayed in the console: Uncaught TypeError: Cannot read property 'addEventListener' of undefined at ne ...

Is it possible to modify the font size of all text that shares a particular font size?

Lately, I've been pondering on a question. A few years ago, I created a website using regular CSS and now I want to make some changes to the font sizes. While I know that CSS variables are the recommended solution for this situation, I'm curious ...

PHP code fails to set a hidden element within a form array

My current project involves sifting through a modest PHP application to debug and enhance it. One snag I've come across is that what should be updates are instead treated as deletes and inserts. To rectify this, I've made some adjustments. Speci ...

Managing information in a fresh window from the main source

I'm looking to use the window open() function to display a default calibration image initially Then have the ability to switch out images from a gallery on the parent page whenever needed My coding skills are a bit rusty, and I'm struggling to ...

Unexpected Results from Div Positioning

Here is the PHP code snippet I am working on: <?php include 'header-adminpanel.php'; ?> <div class="container"> <div class="body-content"> <div class="side-left"><?php include 'adminproduct_sidebar.ph ...

Confirm Submission Issue in HTML Form

During my testing of the blacklist confirmation dialog, I encountered an issue where clicking the OK button did not submit the form as expected. Instead, it seemed to be stuck in a loop where clicking the button had no effect and the dialog remained on scr ...

How to position an absolute div in the center of an image both vertically and horizontally

Can someone help me figure out how to center a div inside an image? I seem to be having trouble with the positioning and alignment. Any suggestions or advice would be greatly appreciated. Thanks! .template-banner{ width: 100%; height: auto; margin: 0; } ...

Recalling a hidden div in a flexbox arrangement

I am facing a challenge with hiding and displaying two aside divs to enable a fullscreen view of my central div main. The layout is created using flexbox to assign proportions, but when I try to redisplay the elements, it disrupts the original design. Belo ...

Relocating to the middle of the webpage (Automatically resize for mobile compatibility if feasible)

Apologies for my poor English. Are there any suggestions on how to center this without using margins or other methods? Perhaps there are alternative solutions. https://i.sstatic.net/dXfwL.png Also, is it feasible for the image and video to automatically a ...

Navigate post Ajax call

When I make an unauthenticated GET request using AJAX, my server is supposed to redirect my application. However, when I receive the redirect (a 303 with /login.html as the location), the response tab in the Firebug console shows me the full HTML of the lo ...