Skip to content

Latest commit

 

History

History
75 lines (50 loc) · 2.65 KB

File metadata and controls

75 lines (50 loc) · 2.65 KB
title slug page-type browser-compat
::backdrop
Web/CSS/::backdrop
css-pseudo-element
css.selectors.backdrop

{{CSSRef}}

The ::backdrop CSS pseudo-element is a box the size of the {{Glossary("viewport")}}, which is rendered immediately beneath any element being presented in the {{glossary("top layer")}}.

{{EmbedInteractiveExample("pages/tabbed/pseudo-element-backdrop.html", "tabbed-shorter")}}

Syntax

::backdrop {
  /* ... */
}

Description

Backdrops appear in the following instances:

  • Elements which have been placed in fullscreen mode using the Fullscreen API {{domxref("Element.requestFullscreen()")}} method.
  • {{HTMLElement("dialog")}} elements that have been shown in the top layer via a {{domxref("HTMLDialogElement.showModal()")}} call.
  • {{domxref("Popover API", "Popover", "", "nocode")}} elements that have been shown in the top layer via a {{domxref("HTMLElement.showPopover()")}} call.

When multiple elements have been placed into the top layer, each one has its own ::backdrop pseudo-element.

/* Backdrop is only displayed when dialog is opened with dialog.showModal() */
dialog::backdrop {
  background: rgb(255 0 0 / 25%);
}

Elements are placed in a last-in/first out (LIFO) stack in the top layer. The ::backdrop pseudo-element makes it possible to obscure, style, or completely hide everything located below a top layer element.

::backdrop neither inherits from nor is inherited by any other elements. No restrictions are made on what properties apply to this pseudo-element.

Examples

Styling the backdrop for fullscreen video

In this example, the backdrop style used when a video is shifted to fullscreen mode is configured to be a grey-blue color rather than the black it defaults to in most browsers.

video::backdrop {
  background-color: #448;
}

The resulting screen looks like this:

An almost full-screen video player with purple above and below the player as the video player doesn't completely fill the screen.

See this example in action, after changing the color of the background cause the video to go fullscreen to see the change to the backdrop color.

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also