Skip to content

Instantly share code, notes, and snippets.

@Osmose
Created June 21, 2015 01:08
Show Gist options
  • Save Osmose/0a0c7c6656dfcee3b902 to your computer and use it in GitHub Desktop.
Save Osmose/0a0c7c6656dfcee3b902 to your computer and use it in GitHub Desktop.
CSS Edge Bounce

CSS bounce effect on hover for long filenames in a music player.

Preview

<h2 className="name">
    <span className="info-line-wrapper">
        <span className="info-line">
            Some long audio filename
        </span>
    </span>
</h2>
<h3 className="artist-album">
    <span className="info-line-wrapper">
        <span className="info-line">
            Name / Album
        </span>
    </span>
</h3>
.audiofile-info:hover .info-line-wrapper {
    position: absolute;
    width: 100%;
    animation: horizontalBounceWrapper 5s linear infinite;
}

.audiofile-info:hover .info-line {
    position: absolute;
    animation: horizontalBounceChild 5s linear infinite;
    width: auto;
    min-width: 100%;
}

@keyframes horizontalBounceWrapper {
    0% {
        transform: none;
    }

    30% {
        transform: translateX(100%);
    }

    50% {
        transform: translateX(100%);
    }

    80% {
        transform: none;
    }
}

@keyframes horizontalBounceChild {
    0% {
        transform: none;
    }

    30% {
        transform: translateX(-100%);
    }

    50% {
        transform: translateX(-100%);
    }

    80% {
        transform: none;
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment