Transition background-color via slide animation

In order to slide the background color up you would need to use a background image, or a gradient of some sort, while gradually adjusting the background-position:

.box {
    width: 200px; height: 100px;
    background-size: 100% 200%;
    background-image: linear-gradient(to bottom, red 50%, black 50%);
    -webkit-transition: background-position 1s;
    -moz-transition: background-position 1s;
    transition: background-position 1s;
}

.box:hover {
    background-position: 0 -100%;
}
<div class="box"></div>

Leave a Comment

tech