html,body {
    height:100%;
    display:flex;
    align-items: center;
    justify-content: center;
    background-color: gray;
}


.box {
    width:200px;
    height:60px;
    border:2px solid black;
    text-align: center;
    font-size: 30px;
    line-height: 60px;
    font-family: Arial, Helvetica, sans-serif;
    overflow: hidden;
    cursor: pointer;

}

.box span {
    display: inline-block;
    color:cyan;
    transition: 0.5s;
}
    .box span:nth-child(odd) {
        transform: translateY(-100%);
    }
    
    .box span:nth-child(even) {
        transform: translateY(100%);
    }
    
    .box span::before {
        content: attr(data-text);
        position: absolute;
        color: tan;
    }
    
    .box span:nth-child(odd)::before {
        transform: translateY(100%);
    }
    
    .box span:nth-child(even)::before {
        transform: translateY(-100%);
    }
    
    .box:hover span {
        transform: translateY(0);
    }

