Element Style Does Not Align with Computed Z-Index

Currently, I am in the process of developing an HTML5 video player. However, I have encountered a problem where my custom controls become unclickable once the video element is set to fullscreen mode. This issue arises because the video's z-index is set to the maximum integer value, which is the same as the controls' z-index. It should be noted that the default browser media controls are already hidden.

<div id="video-container">
  <video frameborder='0' id="page-video" playsinline>
        <source src='{{source}}'>
  </video>
  <div class="container" id="player-controls">
     <!-- custom controls go here -->
  </div>
</div>

Below is the CSS for the video container when in fullscreen mode:

#video-container {
position: relative;
max-width: 512px;
margin: 0 auto;
}

And here is the CSS for the video itself when in fullscreen:

#page-video:-webkit-full-screen {
width: 100%;
height: 100%;
position: relative;
z-index: 1 !important;
}

Lastly, here is the CSS for the custom controls:

#player-controls {
position: absolute;
bottom: 0;
left: 0;
max-width: 100%;
height: auto;
margin: 0 auto;
background: rgba(255, 255, 255, 0.8);
visibility: hidden;
transition: all .2s linear;
padding: 0;
width: 100%;
z-index: 2147483647; 
cursor: pointer;
}

When inspecting the elements using Chrome Dev Tools, it was found that the computed z-index for the video element changes from 'auto' when not in fullscreen to '2147483647' when fullscreen. However, upon expanding the arrow to view the styles, it shows 'z-index: 1 !important' as specified in my stylesheet. This style is not overridden or crossed out, which has left me puzzled. These are the only two instances where z-index is utilized in my entire stylesheet, and there are no negative values assigned anywhere.

Answer №1

When using the video tag, it will override any z-index you apply to it and instead use the default UA styles of "auto" and 2147483647 unless you specifically set position: absolute or position: fixed. For more information, check out this Stack Overflow thread on HTML5 video ignoring z-index

Answer №2

To remove the default controls from a video player, you can disable them by using the "controls" attribute.

<video controls="false">...</video>

However, in some browsers, there may be a bug where the native controls are still visible in fullscreen mode. To fix this issue, you can use CSS to manually hide the controls:

video::-webkit-media-controls {
    display:none !important;
}

If you want to show your own custom controls instead, you can simply set the z-index value to the maximum integer:

#player-controls {
    z-index: 2147483647;
}

You can find more information about creating custom controls for HTML5 video players in this blog post: https://css-tricks.com/custom-controls-in-html5-video-full-screen/

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

The jsonGenerator is unable to process strings containing spaces

Hey, I'm having trouble passing a string with whitespaces to my JavaScript function using jsonGenerator. Here's the code snippet: jGenerator.writeStringField(cols[8], ap.getContentId() != null ? "<img src='img/active.png' onclick=au ...

Create a div element within the parent window of the iFrame

I'm trying to figure out how I can click a button within an iFrame that contains the following code: <td class="id-center"> <div class="bs-example"> <a id="comments" href="comments.php?id=$id" name="commen ...

When a nested CSS Grid is inserted into an HTML table element, it causes horizontal overflow

     Generating an invoice dynamically with a CSS grid poses some challenges. To maintain a specific format, I need to define the number of rows and columns in advance along with column widths. Using template rows and columns for this purpose restrict ...

What measures can be taken to guarantee that a user is only able to delete designated records?

When it comes to writing SQL commands directly, it's simple to specify which records to delete using identifiers like ID. However, when dealing with webpages that contain a list of links pointing to different records (with the ID embedded as a query ...

The Bootstrap modal backdrop is now displaying prominently in front of the modal following the latest Chrome update

Chrome version: Version 111.0.5563.64 (Official Build) (x86_64) Bootstrap: 4.3.1 Recently, there has been an issue with the modal backdrop appearing in front of the modal itself after a Chrome update. The problem does not seem to be related to z-index, an ...

The styling options for PHP table are limited

I have been assigned a task for homework that involves connecting a MySQL database to our PHP files and displaying the data in an HTML table. Although I have successfully connected to the database, I am facing difficulties styling the table. All other elem ...

Generate HTML output from the container element of a Vue application

On my HTML page, I have integrated a Vue application that consists of a single component. This application is attached to an element with the id paid-content. index.html <div id="paid-content"> <h2>You should see this if you' ...

Having trouble getting the Click Element with CSS selector to function properly in Google Tag Manager?

How can I detect a click on the specified element by using the "Click Element" variable in Google Tag Manager? <a href="https://amazon.in/product-id" target="_blank" class="amazon-btn"> <div> <span&g ...

What is the best way to disable the functions doajax_red and doajax_blue when a radio button is checked?

Is there a way to halt the functions doajax_red and doajax_blue when a radio button is checked? Upon loading the page index.php, clicking the red button will display a loading image. If you check the BLUE radio button and then re-check the RED radio butt ...

Trigger the activation of an input field upon clicking an image labeled "edit"

I am currently developing a website where administrators have access to a dashboard page that displays a list of users. I am looking to implement a feature that allows admins to change the roles of other users directly from the same table row. Below is th ...

Retrieve all div elements by their data attribute until reaching a certain condition

I am working on an innovative jquery accordion menu using divs instead of the typical li tags. Each div contains a unique data attribute (data-level) with values ranging from 1 to 4, and so on... To achieve the desired functionality, my "toggle" function ...

Encountering a problem while verifying pattern using regular expressions

I'm facing an issue when manually checking if my inputs match the specified patterns. Below is the function I am using for this check: if (!$element.attr("pattern")) return true; let pattern = $element.attr("pattern"); le ...

Encountering a bug within a PHP webpage that was functioning perfectly until I made some minor adjustments

Encountering an issue in a PHP page after making some small changes. The error is caused by this line of code: $type = (int)$_POST['type']; Error message: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier ( ...

How can you apply an active class using React-Router?

My React-Router navigation issue nav.tsx import React from 'react' import { menu } from './menu' import { Link } from 'react-router-dom' import styles from './HamburgerMenu.module.scss' const HamburgerMenu: React.F ...

I want to adjust the size of a <div> element as an image is being resized using Bootstrap's "img-responsive" class

When adjusting the browser size, the images are resized which is great because it's exactly what I intended. However, the lower part of the black area does not resize accordingly. This results in a black area appearing under the images when viewed on ...

How to adjust animation timing for various elements during a CSS 3D flip with a delay?

Here is a CSS flip setup that I have been working on in this fiddle: http://jsfiddle.net/6r82fzk6/ The Goal: I am trying to achieve a slower transition for the back element compared to everything else. The idea is to have the child element of the back fac ...

Getting access to the current row along with its value within an AngularJS application

Seeking guidance on how to edit and remove a row in angularjs as I am new to it. In my dynamic table, rows are inserted dynamically with links for editing and deleting. I am looking to edit a row upon clicking the edit link. HTML Code: <div ng-contro ...

How come the data I send gets converted to Undefined when working with Tabulator?

I am currently facing an issue with integrating JSON data as search results into my Tabulator. The goal is to display these search results in their respective columns within the Tabulator. Here is the code snippet I have implemented: <body> <div ...

Dynamic HTML text colors that change rapidly

I have an interesting question to ask... Would it be possible to create text that switches between two colors every second? For example, could the text flash back and forth between red and grey? I don't mean changing the background color, I mean act ...

Position elements flush to the left and right

Is it possible to align the text in divs so that it perfectly lines up along the edges? .name { margin: 0 0 5px 10px; font-weight: bold; font-size: 14px; } .row { margin: 0 0 5px 10px; width: 500px; justify-content: space-between; } < ...