aristillus
2/26/2018 - 8:25 AM

Сдвигающийся при наведении элемент

html,
body {
    margin: 0;
    padding: 0;
    font-family: "Roboto", sans-serif;
    font-size: 14px;
    color: #333333;
    background: #f5f5f5;
}

.works {
    width: 240px;
    margin: 100px auto;
    padding: 20px;
    background: white;
    box-shadow: 0 0 3px #cccccc;
}

.caption-link {
    position: relative;
    z-index: 1;
    display: block;
    overflow: hidden;
}

.caption-link img {
    display: block;
    max-width: 100%;
    transition: transform 0.3s ease;
}

.caption-link:hover img {
    transform: translateX(100%);
}

.caption-link::before,
.caption-link::after {
    position: absolute;
    z-index: -1;
    width: 100%;
    text-align: center;
    background: #333333;
    box-sizing: border-box;
    transition: transform 0.3s ease-in-out;
    transform: translateX(-80px);
}

.caption-link::before {
    content: attr(data-title);
    height: 30%;
    padding: 30px;
    font-size: 22px;
    font-weight: bold;
    color: #ffffff;
}

.caption-link::after {
    content: attr(data-description);
    top: 30%;
    height: 70%;
    padding: 0 30px;
    color: #d7bb97;
}

.caption-link:hover::before,
.caption-link:hover::after {
    transform: translateX(0);
}
<!DOCTYPE html>
<html lang="ru">
    <head>
        <title>Выдвигающееся описание, шаг 3</title>
        <meta charset="utf-8">
        <base href="/assets/course76/">
        <link href="//fonts.googleapis.com/css?family=Roboto:500,300&subset=latin,cyrillic-ext" rel="stylesheet" type="text/css">
    </head>
    <body>
        <section class="works">
            <a class="caption-link" href="#" data-title="Sunset" data-description="Сайт туристического агентства, специализирующегося на незабываемых поездках в тёплые страны.">
                <img src="shot-1.jpg" alt="Sunset">
            </a>
        </section>
    </body>
</html>