JSFiddle - React, Tailwind, and code Playground

by hfougere

HTML

<div class="image-block">
    <h1>Hello world</h1>
</div>

CSS

html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    font-family: 'Roboto', sans-serif;
}
 
.image-block {
    position: relative;
    width: 100%;
    height: 100%;
    background: url('http://unsplash.it/1200x800') center center no-repeat;
    background-size: cover;
    &::after {
        content: '';
        background: rgba(0, 0, 0, 0.8);
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 1;
        opacity: 0;
        transition: opacity 1s ease-in-out;
    }
 
    &:hover:after {
        opacity: 1;
    }
 
    h1 {
        color: #fff;
        z-index: 2;
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
    }
}