Displaying videos in Vue js with full width and height is not working as expected

I am trying to create something similar to this:

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

However, the video does not display in full height and width. Instead, it appears cut off at the edges and I cannot see the controls.

I want the video to cover 100% of the height and width.

My CSS code for this component looks like this:

.screensaver {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: gray;
    z-index: 9000;

    .logo{
        background-image: url(~@/assets/test.svg);
    }

    &-header {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        background-image: linear-gradient(180deg, rgba(0,0,0,0.5) 0%, rgba(0,0,0,0.00) 100%);
        z-index: 1500;
        display: flex;
        align-items: center;
        padding: $layout-size*1.25 $layout-size;

        &-left{
            flex: 0 0 320px;
        }
    }

    &-body {
        top: 0;
        position: absolute;
        height: 100vh;
        width: 100vw;

        &:after{
            content:'';
            background-color: rgba(0,0,0, 0.5);
            width: 100%;
            height: 100%;
            position: absolute;
            top: 0;
            left: 0;
        }

        video{
            min-height: 100%;
            min-width: 100%;
            height: 100vh;
            display: block;
        }

        &-center {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            text-align: center;
            z-index: 10;            
        }
    }
}

================= My Vue template:

<template>
    <div class="screensaver">
        <div class="screensaver-header">
            <div class="screensaver-header-left">
                <span class="logo">Test</span>
            </div>
        </div>
        <div class="screensaver-body">
            <video controls autoplay muted loop>
                <source :src="require('test.mp4')" type="video/mp4">
            </video>
            <div class="screensaver-body-center">
                <span>icon</span>
                <h2>Please touch to unlock</h2>
            </div>
        </div>
      </div>

Answer №1

Discovered a workaround for the issue at hand. By modifying the Video Object, we can alter the video's appearance, although the adjustments are minimal and can be implemented without difficulty.

video {
    height: 100vh;
    width: 100vw;
    object-fit: cover; /*changed from fill to 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 could be causing the footer to not show up at the bottom of the page?

I've encountered an issue with my code where the footer appears to be stuck at the bottom of the h2_c div instead of the bottom of the .content div where it should be. I have tried using positioning but it hasn't resolved the problem. Thank You. ...

Painting issue on Chrome and Opera browsers

I've discovered a strange issue with my page rendering in blink browsers where it paints and then suddenly "unpaints." Once the page has loaded, most of the viewport becomes blank and stops painting. Here is how the screen should look after I manually ...

Align the responsive image in the center of a container

I am facing a challenge in centering an image wrapped by an anchor tag inside a div. I have tried using display flexbox and justify-content:center for the image, which works to some extent. However, the height of the image remains constant while the width ...

Create a non-responsive, one-line navbar for mobile in Bootstrap 4 that does not wrap around

I'm looking for a way to make my Bootstrap 4 navbar non-responsive with the toggler. Here is the issue I'm facing: Current Navbar in big screen: https://i.sstatic.net/e3f3p.png Navbar in mobile view:https://i.sstatic.net/7jMi5.png What I want ...

Applying a variety of elements to a single function

I am in the process of creating a mini-survey and I want the buttons to change color when clicked, but return to normal when another button is selected within the same question. Currently, clicking on a button turns it red while leaving the others clear. H ...

"Triggering the scrollTop animation will trigger the scroll event to

I am facing an issue with my code that tracks the scrolling of a page. It successfully performs the necessary action when the "page" changes, but I am having trouble preventing the scroll event from being triggered when animating the scrollTop to the neare ...

Improving code quality and consistency in Javascript: Tips for writing better code

Hey, I've been experimenting with some code using ajax and have ended up with a lot of repetitive lines. Is there a way to streamline the code without losing functionality? I keep using the .done method multiple times when I could probably just use it ...

Showcasing only one item at a time in AngularJS 1.x with ng-repeat; by clicking on "next", the subsequent item will be displayed,

Currently, I am working on a quiz web application that requires displaying a total of 100 questions across 3 different tabs - Math, GK, and English. The questions are filtered using an Angular filter. However, I'm facing an issue where each tab is sho ...

Validating Forms in AngularJS: Ensuring At Least One Input Field is Not Empty

Consider the following basic HTML form: <form name="myForm" action="#sent" method="post" ng-app> <input name="userPreference1" type="text" ng-model="shipment.userPreference" /> <input name="userPreference2" type="text" ng-model="shipm ...

What is the best way to pass a variable from one PHP file to another?

This question may seem like a duplicate, but I found no helpful answers elsewhere. I'm in the process of creating a website where users can respond to various types of questions. To achieve this, I've written code that displays the corresponding ...

Troubleshooting Vue 3: Issues with retrieving input field values

Vue 3 has been a bit challenging for me to grasp, especially related to making axios calls and handling input field values. In my Vue installation folder, I am trying to retrieve input values from the form fields to implement a login function which at lea ...

Embarking on the journey of creating mobile web applications - where should you begin?

How can I begin learning to create mobile web apps? I have a keen interest in the design aspects, particularly the effects and animations that give them a native appearance. I suspect there are differences in CSS, HTML, and possibly JavaScript compared to ...

What are the steps to develop a Vue application with a built-in "add to desktop" functionality?

Looking to develop a Vue application with the feature of adding to desktop, similar to the option near the share button on YouTube. Any suggestions on how to achieve this? https://i.stack.imgur.com/nXG4i.png ...

Is it a good idea for the poster image to vanish too quickly before the video starts playing in HTML5?

Recently, I implemented a full-width background video on my website at www.sparkengine.tv. While the site is still a work in progress, some users have reported seeing the poster image before it disappears right before the video loads, creating a less-than- ...

What could be causing the image to peek through the color overlay?

When I add a black overlay to images, I notice that the edges of the row of images slightly peek out from under the overlay. The size of the images seems to affect this issue differently. Check out the CodePen below to see it in action with Bootstrap 4 CSS ...

The Python socket fails to receive a valid response after sending an HTTP 1.1 CONNECT request

I am attempting to create a simple program that establishes an https tunnel with www.google.com on port 443. Initially, I used the code below: import socket def main(): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(("www.google. ...

When a web page is translated using Google Translate, Vue components may cease to update properly

When Vue components on pages are translated using Chrome's translate feature, the components stop re-rendering and updating the view. For example, if you try to translate https://v2.vuejs.org/v2/guide/#Handling-User-Input in Chrome to a different lan ...

Send information from Node.js to the webpage and populate designated elements (search by either ID or class) on the webpage

After successfully retrieving data from the mongo database using nodejs, my goal is to display this data on a webpage. function requireUser(req, res, next){ //console.log(req.session.username); if (!req.session.username) { res.redirect('/user_un ...

What steps can I take to embed a video in HTML without autoplaying in a browser?

I have a simple but important question that I need help with. I am creating a compilation of family videos and I want to put them all on one page or in an HTML file. However, when I embed/link a directory file of the video into the HTML, it automatically ...

Updating variable values in AngularJS while navigating through routes

How can I dynamically set the flag icon inside the page header based on the selected language using AngularJS? The language selection is done in a separate .htm file and all managed by AngularJS routing. My application has a single controller called "appCo ...