"Experiencing the immersive beauty of a full-screen

This is my first attempt at a web video project and I'm struggling to create a full-width video header or background. Any help would be greatly appreciated.

I came across an example that achieves what I am looking for with the following specifications: .mp4 file in 640x360 format @ 23 fps (613kbps) which works perfectly on all displays, showing the entire frame without any issues.

After some research, I found that the recommended video format is 720 x 24fps, so I gave it a try with actual dimensions of 1280x720. However, I noticed that it only looks good on browser resolutions less than maximized, as part of the bottom section (about 18% of the frame) remains invisible until you scroll down. Buffering was also an issue with the 720 format, unlike the smooth playback of the 640x360.

The video editing software I use (Sony Vegas) does not offer a 640x360 option, with the closest being 640x480 which results in the same problem - the video being too tall with the bottom portion cut off.

I found a website that utilizes the 1280x720 format successfully (), but I am unsure how they achieved it.

If anyone could provide guidance on how to make the video work seamlessly while maintaining visibility of the whole image, I would be grateful.

Thank You.

Here's the current code:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Video test</title>;

<script>
$(document).ready(function () {
$(".player").mb_YTPlayer();
});
</script>

<style>
body{ margin:0px; background:#000; max-width:1000; }
#bg_container{ height:800px; overflow:auto; }
#bg{ width:100%; }
</style>

</head>

<body>

<div id="bg_container">
  <video id="bg" src="www.parishpc.com/images/720.mp4" autoplay loop muted"></video>
</div>

</body>
</html>

A slightly improved version of the code, where only the bottom 5% is not visible:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Video test</title>

<style>

body, html { 
margin: auto;
background:#fff;
height: 100%;
}

header {
height:100%;
width:100%;
overflow:hidden;
position:relative;
}

.video {
    position:fixed;
    top: 50%; left: 50%;
    z-index:1;
    min-width: 100%;
    min-height: 100%;
    width:auto;
    height:auto;
    transform: translate(-50%,-50%);
}
</style>

</head>

<body>
    <header>
        <video autoplay loop class="video">
            <source src="www.parishpc.com/images/720.mp4" type="video/mp4">
        </video>
    </header>        
</body>
</html>

Answer №1

For those still attempting to expand the video to occupy the entire viewport, you can achieve this using the code below -> (It seems likely that adding the video via the tag in your .html file is necessary rather than setting it as a background in your CSS)

Specify the parent container you want the video to fill with:

position: relative;

Add these properties to your video element:

height: 100vh;
width: 100vw;
position: absolute;
top: 0;
left: 0;
z-index: -2;
object-fit: fill;

Answer №2

Give this a shot

html {
   font-size: 16px;
}

and delete display: flex; from the container element

Hopefully, this will resolve your issue

Feel free to reach out if you need more assistance

Answer №3

It can be challenging to create a video background that fits perfectly on every user's screen without any stretching or cutoff parts.

To ensure the video covers 100% of the window's height, users may need to adjust the window size to view any cropped sections.

<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>Video test</title>

    <style>
        body {
            margin: 0;
            padding: 0;
        }

        #container {
            height: 100%;
            width: auto;
        }

        .video {
            height: 100%;
        }

    </style>

</head>

<body>
    <div id="container">
        <video autoplay loop class="video">
            <source src="http://www.parishpc.com/images/720.mp4" type="video/mp4">
        </video>
    </div>
</body>

</html>

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

Why does the value of my input get erased when I add a new child element?

I seem to be facing an issue when I try to add an element inside a div. All the values from my inputs, including selected options, get cleared. Here's a visual representation of the problem: https://i.sstatic.net/UpuPV.gif When I click the "Add Key" ...

Troubleshooting Problem with HTML Links in jQuery Accordion

After experimenting with adding a link to the HTML section of the accordion, I discovered that the link appears bold and does not open. I attempted to create a class or ID to fix this issue, but my efforts were unsuccessful. http://jsfiddle.net/q2Gm9/ ...

Animating SVG elements using CSS

After learning how to use the <animate> attribute, I successfully created a captivating animation featuring an elastic line. However, I am now determined to transform this into CSS for better control: my goal is to activate the animation only upon ho ...

New and improved Bootstrap 5 menu bar

I am seeking to customize my navigation bar by adding a black background that spans its entire length. I do not want to rearrange the links or logo; just apply a background color. Another issue arises during SASS compilation: I am trying to change the col ...

React Native: Image not aligning vertically center in text within nested elements

Issue Description I am facing a challenge in nesting multiple images within a paragraph. If it were just a single line of text, I could have easily used a <View> with flexDirection: 'row'. Since that approach doesn't fit the requireme ...

React Native CSS Triangles not functioning anymore

I'm currently developing an application that involves triangles overlaying other containers and divs. This issue was previously resolved using CSS with the following code: .triangle:after { content: ""; display: block; position: absolu ...

When attempting to unmarshal JSON with HTML escaped strings, an error is encountered stating "invalid character 'T' after object key:value pair"

Currently, I am facing a challenge in unmarshalling a JSON object in GO, here is an example: { "label": "The quick &quot;brown fox&quot; jumps over the &quot;lazy dog&quot;", "value": "dummy value& ...

Creating adjustable absolute positioned elements in Bootstrap 4 for optimal responsiveness

Is there a Bootstrap 4 class that can help me position an absolute yellow color container in a responsive way across all devices, without the need for writing multiple media queries? I want to achieve a screen layout like this on my webpage. Any suggestion ...

Tips for cropping an image using CSS with dimensions specified for width, height, and x and y coordinates

As I work on implementing a cropping feature using react-easy-crop, my goal is to store the user's image along with pixel coordinates that dictate their preferred cropping area. My objective is to utilize the parameters provided by react-easy-crop in ...

"An innovative social media platform feature resembling a Linkedin/Facebook post box

I am looking to develop a post box feature similar to LinkedIn and Facebook. When a URL is pasted into the box, I want a thumbnail to be generated. Two main questions: - Is there an existing component that already does this? I have searched extensively b ...

AngularJS Input field fails to update due to a setTimeout function within the controller

I am currently working on a project that involves AngularJS. I need to show a live clock in a read-only input field, which is two-way bound with data-ng-model. To create this running clock effect, I am using a JavaScript scheduler with setTimeout to trigge ...

Change when the mouse departs

I am currently working on implementing a transition effect. My block consists of 3 main parts: Base block Hover image (coming from the top) Hover title (coming from the bottom) When hovering the mouse, there is also a background-color transition that o ...

Passing PHP value from a current page to a popup page externally: A guide

I'm currently facing an issue at work where there is a repetitive button and value based on the database. I need to extract the selected value from the current page into a pop-up page whenever the corresponding button is clicked throughout the repetit ...

Issue with sending an ajax post request using Jquery

The jquery ajax request below is not working as expected: $(document).ready(function(){ var friendrequest = $(".friendrequest").val(); $(".afriendreq").click(function(){ $(".afriendreq").hide(); ...

Click to Rotate the Shape

I am attempting to apply a rotation effect on a shape when clicked using jQuery and CSS. My goal is to select the element with the id of x and toggle the class rotate on and off. The rotate class utilizes the CSS transform property to achieve the desired r ...

Problem occurring with Bulma CDN version 0.8.0 failing to identify the spacing helper

Recently revisited an older project I had started some time ago using the Bulma framework. However, for some reason, the 0.8.0 CDN is not being imported or recognized correctly by the spacing classes. Here's the code snippet I had initially: <link ...

When an HTML table utilizes both rowspan and colspan attributes, it may encounter issues with being overlapped by the

I'm working on a straightforward table that showcases the properties of a data element. Each row will represent an element from the AJAX response in a list format. The table is designed with "rowspan" and "colspan" to expand specific cells. However, ...

Injecting a full browser-screen DIV into the body of the webpage

Recently, I was tasked with developing a script that could be utilized on any website. As a test, I decided to use the Google search results page. My goal is simple - to have a full-screen semi-transparent div displayed on any site for cookie notification ...

Steps for deactivating tab stops on the primary webpage in the presence of a snackbar

On my web page, there are multiple drop-down menus, input fields, and buttons that can be interacted with using both the tab key and mouse. After entering certain data, I trigger a snackbar (source: https://www.w3schools.com/howto/howto_js_snackbar.asp) t ...

React Intersection Observer not functioning properly

Hey there! I'm trying to create an animation where the title slides down and the left element slides to the right when scrolling, using the intersection observer. Everything seems to be fine in my code, but for some reason it's not working. Any t ...