Эффекты при наведении на картинку с появлением и подчеркиванием заголовка. Для удобства копирования в каждую вкладку CSS добавлены общие стили. Эти эффекты можно использовать для галереи и для карточек товаров.
Пример
HTML
<!-- Первая картинка -->
<div class="hover-text-one">
<figure class="effect-text-three">
<img src="image.jpg" alt=""/>
<figcaption>
<h3>Lorem ipsum</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit</p>
</figcaption>
</figure>
</div>
<!-- Вторая картинка -->
<div class="hover-text-one">
<figure class="effect-text-four">
<img src="image.jpg" alt=""/>
<figcaption>
<h3>Lorem ipsum</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit</p>
</figcaption>
</figure>
</div>
CSS 1
/* Общие стили */
*, *:after, *:before {
border-box;
box-sizing: border-box;
}
.clearfix:before, .clearfix:after {
content: '';
display: table;
}
.clearfix:after {
clear: both;
}
.hover-text-one {
overflow: hidden;
margin: 0;
width: 100%;
list-style: none;
text-align: center;
}
.hover-text-one figure {
position: relative;
z-index: 1;
display: inline-block;
overflow: hidden;
background: #527c82;
text-align: center;
cursor: pointer;
}
.hover-text-one figure img {
position: relative;
display: block;
min-height: 100%;
opacity: 0.8;
}
.hover-text-one figure figcaption {
padding: 2em;
color: #fff;
text-transform: uppercase;
font-size: 1.25em;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
}
.hover-text-one figure figcaption::before,
.hover-text-one figure figcaption::after {
pointer-events: none;
}
.hover-text-one figure figcaption{
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.hover-text-one figure h3 {
word-spacing: -0.15em;
font-weight: 300;
}
.hover-text-one figure h3 span {
font-weight: 800;
}
.hover-text-one figure h3,
.hover-text-one figure p {
margin: 0;
}
.hover-text-one figure p {
letter-spacing: 1px;
font-size: 68.5%;
}
/* Эффект при наведении */
figure.effect-text-three {
background: #527c82;
}
figure.effect-text-three img {
width: -webkit-calc(100% + 20px);
width: calc(100% + 20px);
-webkit-transition: opacity 0.35s, -webkit-transform 0.35s;
transition: opacity 0.35s, transform 0.35s;
transform: scale(1.1);
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
}
figure.effect-text-three:hover img {
opacity: 0.4;
-webkit-transform: translate3d(0,0,0);
transform: translate3d(0,0,0);
}
figure.effect-text-three figcaption {
text-align: left;
}
figure.effect-text-three h3 {
position: relative;
overflow: hidden;
padding: 0.5em 0;
}
figure.effect-text-three h3::after {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 3px;
background: #fff;
content: '';
-webkit-transition: -webkit-transform 0.35s;
transition: transform 0.35s;
-webkit-transform: translate3d(-100%,0,0);
transform: translate3d(-100%,0,0);
}
figure.effect-text-three:hover h3::after {
-webkit-transform: translate3d(0,0,0);
transform: translate3d(0,0,0);
}
figure.effect-text-three p {
padding: 1em 0;
opacity: 0;
-webkit-transition: opacity 0.35s, -webkit-transform 0.35s;
transition: opacity 0.35s, transform 0.35s;
-webkit-transform: translate3d(100%,0,0);
transform: translate3d(100%,0,0);
}
figure.effect-text-three:hover p {
opacity: 1;
-webkit-transform: translate3d(0,0,0);
transform: translate3d(0,0,0);
}
CSS 2
/* Общие стили */
*, *:after, *:before {
border-box;
box-sizing: border-box;
}
.clearfix:before, .clearfix:after {
content: '';
display: table;
}
.clearfix:after {
clear: both;
}
.hover-text-one {
overflow: hidden;
margin: 0;
width: 100%;
list-style: none;
text-align: center;
}
.hover-text-one figure {
position: relative;
z-index: 1;
display: inline-block;
overflow: hidden;
background: #527c82;
text-align: center;
cursor: pointer;
}
.hover-text-one figure img {
position: relative;
display: block;
min-height: 100%;
opacity: 0.8;
}
.hover-text-one figure figcaption {
padding: 2em;
color: #fff;
text-transform: uppercase;
font-size: 1.25em;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
}
.hover-text-one figure figcaption::before,
.hover-text-one figure figcaption::after {
pointer-events: none;
}
.hover-text-one figure figcaption{
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.hover-text-one figure h3 {
word-spacing: -0.15em;
font-weight: 300;
}
.hover-text-one figure h3 span {
font-weight: 800;
}
.hover-text-one figure h3,
.hover-text-one figure p {
margin: 0;
}
.hover-text-one figure p {
letter-spacing: 1px;
font-size: 68.5%;
}
/* Эффект при наведении */
figure.effect-text-four figcaption {
text-align: right;
}
figure.effect-text-four h3,
figure.effect-text-four p {
position: absolute;
right: 30px;
left: 30px;
padding: 10px 0;
}
figure.effect-text-four p {
bottom: 30px;
line-height: 1.5;
-webkit-transform: translate3d(0,100%,0);
transform: translate3d(0,100%,0);
}
figure.effect-text-four h3 {
top: 30px;
-webkit-transition: -webkit-transform 0.35s;
transition: transform 0.35s;
-webkit-transform: translate3d(0,20px,0);
transform: translate3d(0,20px,0);
}
figure.effect-text-four:hover h3 {
-webkit-transform: translate3d(0,0,0);
transform: translate3d(0,0,0);
}
figure.effect-text-four h3::after {
position: absolute;
top: 100%;
left: 0;
width: 100%;
height: 4px;
background: #fff;
content: '';
-webkit-transform: translate3d(0,40px,0);
transform: translate3d(0,40px,0);
}
figure.effect-text-four h3::after,
figure.effect-text-four p {
opacity: 0;
-webkit-transition: opacity 0.35s, -webkit-transform 0.35s;
transition: opacity 0.35s, transform 0.35s;
}
figure.effect-text-four:hover h3::after,
figure.effect-text-four:hover p {
opacity: 1;
-webkit-transform: translate3d(0,0,0);
transform: translate3d(0,0,0);
}