---
category: Display
created: '2019-11-30'
description: Create an overlay play button with CSS flexbox
keywords: css flexbox
thumbnail: /assets/css-layout/thumbnails/overlay-play-button.png
title: Overlay play button
---

## HTML

```html index.html
<div class="overlay-play-button">
    <!-- The video element -->
    <video src="..." />

    <!-- The overlay area -->
    <div class="overlay-play-button__overlay">
        <!-- The player button -->
        <div class="overlay-play-button__play">...</div>
    </div>
</div>
```

## CSS

```css styles.css
.overlay-play-button {
    /* Used to position the overlay */
    position: relative;
}

.overlay-play-button__overlay {
    /* Position */
    left: 0;
    position: absolute;
    top: 0;

    /* Take full size */
    height: 100%;
    width: 100%;

    /* Center the content */
    align-items: center;
    display: flex;
    justify-content: center;

    /* Add a dark background */
    background-color: rgba(0, 0, 0, 0.25);
}

.overlay-play-button__play {
    border: 0.25rem solid #fff;
    border-radius: 9999px;
    height: 3rem;
    width: 3rem;

    /* Center the content */
    align-items: center;
    display: flex;
    justify-content: center;
}
```

<Playground>
```css placeholders.css hidden
.triangle {
    border-style: solid;
    height: 0;
    width: 0;
}
.triangle--t {
    border-color: transparent transparent #d1d5db transparent;
    border-width: 0 var(--triangle-size) var(--triangle-size) var(--triangle-size);
}
.triangle--r {
    border-color: transparent transparent transparent #d1d5db;
    border-width: var(--triangle-size) 0 var(--triangle-size) 1rem;
}
.triangle--b {
    border-color: #d1d5db transparent transparent transparent;
    border-width: var(--triangle-size) var(--triangle-size) 0 var(--triangle-size);
}
.triangle--l {
    border-color: transparent #d1d5db transparent transparent;
    border-width: var(--triangle-size) 1rem var(--triangle-size) 0;
}
.triangle--tr {
    border-color: transparent #d1d5db transparent transparent;
    border-width: 0 var(--triangle-size) var(--triangle-size) 0;
}
.triangle--br {
    border-color: transparent transparent #d1d5db transparent;
    border-width: 0 0 var(--triangle-size) var(--triangle-size);
}
.triangle--bl {
    border-color: transparent transparent transparent #d1d5db;
    border-width: var(--triangle-size) 0 0 var(--triangle-size);
}
.triangle--tl {
    border-color: #d1d5db transparent transparent transparent;
    border-width: var(--triangle-size) var(--triangle-size) 0 0;
}
.triangle--sm {
    --triangle-size: 0.5rem;
}
.triangle--md {
    --triangle-size: 2rem;
}
.triangle--lg {
    --triangle-size: 4rem;
}
```

```css styles.css hidden
body {
    height: 24rem;
}
.overlay-play-button {
    /* Used to position the overlay */
    position: relative;

    /* Demo */
    height: 100%;
    width: 100%;
}

.overlay-play-button__overlay {
    /* Position */
    left: 0;
    position: absolute;
    top: 0;

    /* Take full size */
    height: 100%;
    width: 100%;

    /* Center the content */
    align-items: center;
    display: flex;
    justify-content: center;

    /* Add a dark background */
    background-color: #4b5563;
}

.overlay-play-button__play {
    border: 0.25rem solid #fff;
    border-radius: 9999px;
    height: 3rem;
    width: 3rem;

    align-items: center;
    display: flex;
    justify-content: center;
}
```

```html index.html hidden
<div class="overlay-play-button">
    <div class="overlay-play-button__overlay">
        <div class="overlay-play-button__play">
            <div class="triangle triangle--r triangle--sm"></div>
        </div>
    </div>
</div>
```
</Playground>
