JSFiddle - React, Tailwind, and code Playground

HTML

<div class="container">
    <div class="highlight"></div>
    <div class="content">Bar</div>
</div>

CSS

.container {
    position: relative;
}

.content {
    background: #88f;
}

.highlight {
    border: 2px solid red;
    background: #f88;

    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
    opacity: 0;

    transition: z-index 0.5s step-end, opacity 0.5s linear;
}
.container:hover .highlight {
    z-index: 1;
    opacity: 1;
    transition: z-index 0.5s step-start, opacity 0.5s linear;
}