Skip to content

Instantly share code, notes, and snippets.

@isabellachen
Created January 27, 2020 14:53
Show Gist options
  • Save isabellachen/f7f9e9d0c4166de904448b573f664f0a to your computer and use it in GitHub Desktop.
Save isabellachen/f7f9e9d0c4166de904448b573f664f0a to your computer and use it in GitHub Desktop.
CSS to create clikable overlay

The idea is to have an overlay on the same level as the modal or widget, so when click the overlay, the modal closes.

<div class="overlay"></div>
<div class="widget"></div>
.widget {
  width: 50px;
  height: 50px;
  background-color: firebrick;
  position: absolute;
}

.overlay {
  position: fixed;
  top: 0;
  left: 0;
  background-color: #dedede;
  width: 100vw;
  height: 100vh;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment