Fullscreen Menu

:fullscreen | CSS-Tricks - CSS-Tricks EmailEmail

:fullscreen

Avatar
Seyedi on (Updated on )

The :fullscreen :fullscreen lets us do.

.element:fullscreen {
  font-size: 3em;
  text-align: center;
}

Fullscreen mode and the Fullscreen API

(+CMD+F on MacOS, F11 :fullscreen, it won’t match that element. Instead, an element matches :fullscreen Fullscreen API.

let element = document.querySelector(".element");

element.requestFullscreen();

<section> :fullscreen, then style accordingly:

section:fullscreen {
  display: flex;
  align-items: center;
  justify-content: center;
}

We can select the children of fullscreen elements

<section> element:

section:fullscreen p {
  font-size: 2em;
}

Trick: Only style when not in fullscreen mode

not in fullscreen mode, we can use it alongside the :not pseudo-class:

section:not(:fullscreen) {
  background: #eee;
}

Browser support

:-ms-fullscreen

IEEdgeFirefoxChromeSafariOpera
11 1All64 271 36 458 5
Android ChromeAndroid FirefoxAndroid BrowseriOS SafariOpera Mobile
AllNo91No62
Source:

1 :-ms-fullscreen
2 :-moz-full-screen
3 Supported as :-webkit-full-screen
4 :-webkit-full-screen
5 :-webkit-full-screen in Opera 15-57+.

View In

To Go Infos