<div class="example-cntr fullscreen">
    <h1>CSS <code>:fullscreen</code> pseudo-class</h1>
    <p>The <code>:fullscreen</code> pseudo-class targets elements that are being displayed in full screen mode.</p>
    <p>However, take note that the <code>:fullscreen</code> pseudo-class <strong class="underline">is not</strong> intended to work when pressing F11 to enter full screen in the browser.</p>
    <p>The way to know if we have entered the full-screen mode is when a message appears on the browser (top or bottom) letting us know that we have entered full-screen mode and that pressing <code>ESC</code> takes us back to the page. We see this when we maximize a video on YouTube or Vimeo.</p>
    <h4>Example - <span class="note">Note: This demo only works on Chrome and Edge.</span></h4>
    <h1 id="element"><span class="hide">The text is injected via CSS</span></h1>
    <button onclick="var el = document.getElementById('element'); el.webkitRequestFullscreen();">Trigger Full Screen!</button>
</div>
#element {
    border-bottom: none;
    background: none;
    //Content in "normal" mode.
    &:before {
        content: 'Normal mode';
    }
    //Content in fullscreen mode
     &:fullscreen:before {
         content: 'Fullscreen mode';         
    }
}


//Styling stuff not needed for demo
body {
    text-align: left;
    line-height: 1.5;
}
h1 {
    font-size: 22px;
    text-transform: none;
    border-bottom: #636363 1px dotted;
    code {
        display: inline-block;
        margin-bottom: 10px;
        color: $y;
        background: none;
        box-shadow: none;
    }
}
h4 { margin-bottom: 15px; }
code { font-size: 1em; }
.example-cntr {
    max-width: 800px;
    margin: 0 auto 50px;
    padding: 30px;
    box-shadow: 0 1px 2px rgba(black,.3);
    background: rgba(black,.15);
    & > code {
        display: block;
        margin-bottom: 10px;
        font-size: 22px;
        color: $y;
        background: none;
        box-shadow: none;
    }
}
.underline { text-decoration: underline; }

//
.hide { display: none; }
#element {
    padding-bottom: 20px;
    &:before { 
        display: block;
        padding: 5px 0;
        background: $b;
    }
    &:fullscreen:before {
        display: block;
        padding: 5px 250px;
        background: $r;
    }    
}
button {
    padding: 8px 15px;
    cursor: pointer;
    background: linear-gradient(white, #aaa);
    border-radius: 2px;
    &:hover { background: white; }
    &:active { background: linear-gradient(#aaa, white 20%);}
}
.note {
    color: desaturate($y,30);
    font-size: 12px;
    letter-spacing: .5px;
}
.fullscreen h1 { margin: 0; }
View Compiled

External CSS

  1. https://s3-us-west-2.amazonaws.com/s.cdpn.io/9988/codepen-base_3.scss

External JavaScript

This Pen doesn't use any external JavaScript resources.