CSS overlay Property
The overlay property keeps an element in the top layer while it animates out, used with transition-behavior: allow-discrete. Only browsers set its value.
Description
The overlay property reports whether an element is in the browser's top layer, the special layer above the rest of the page used by modal dialogs, popovers and fullscreen elements. Its value is auto while the element is in the top layer and none otherwise.
Authors cannot set it to put an element into the top layer; that only happens through APIs such as showModal() or showPopover(). Its purpose is animation: listing overlay in a transition with transition-behavior allow-discrete keeps a closing dialog or popover in the top layer until its exit transition has finished, so it does not drop behind other content while fading out.
[popover] {
transition: opacity 0.3s, overlay 0.3s allow-discrete, display 0.3s allow-discrete;
}Definition
- Initial value
- none
- Applies to
- all elements
- Inherited
- no
- Computed value
- as specified
- Animatable
- discrete
- JavaScript syntax
- object.style.overlay
Syntax
overlay: none | auto;
Values
- noneThe element is not in the top layer.
- autoThe element is in the top layer. This value cannot be set by authors.
- initialSets the property to its initial value.
- inheritTakes the computed value of the parent element.
Example
Browser Support
The following information will show you the current browser support for the CSS overlay property. Hover over a browser icon to see the version that first introduced support for this CSS property.
Desktop





Tablets & Mobile





