Skip to content

Instantly share code, notes, and snippets.

@newtone
Last active December 10, 2020 21:01
Show Gist options
  • Save newtone/3b6047a0e9b56f2e2305b603ae260f4b to your computer and use it in GitHub Desktop.
Save newtone/3b6047a0e9b56f2e2305b603ae260f4b to your computer and use it in GitHub Desktop.
* {
box-sizing: border-box;
}
:root {
--color: rgba(0, 0, 0, 0.55);
}
body {
margin: 0;
pading: 1rem;
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background-color: rgba(183, 216, 232, 1);
}
.element {
position: relative;
width: min(15rem, 80vw);
height: min(15rem, 80vw);
background-color: darkorchid;
}
/* Utility classes */
.overlay-child,
.overlay-before,
.overlay-after {
position: relative;
}
.overlay, /* Applies to the covering element, others apply to the parent */
.overlay-child > *,
.overlay-before::before,
.overlay-after::after {
position: absolute;
content: '';
display: block;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: repeating-linear-gradient(45deg, var(--color), var(--color) 0.5rem, transparent 0, transparent 1rem), rgba(0, 0, 0, 0.2);
}
<div class="element overlay-child">
<div></div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment