Heute zeige ich euch wie man mit wenig Zeilen von Code einen coolen Hover Effekt machen kann, der mich an ein Polaroid-Foto erinnert.
Sehr einfach und schnell gemacht.
Video Anleitung
Quellcode HTML
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| <div class="container">
<div class="wrapper">
<div class="image one"></div>
<div class="caption">
<span>Titel</span><br />
Dies ist eine Beschreibung
</div>
</div>
<div class="wrapper">
<div class="image two"></div>
<div class="caption">
<span>Titel</span><br />
Dies ist eine Beschreibung
</div>
</div>
</div> |
<div class="container">
<div class="wrapper">
<div class="image one"></div>
<div class="caption">
<span>Titel</span><br />
Dies ist eine Beschreibung
</div>
</div>
<div class="wrapper">
<div class="image two"></div>
<div class="caption">
<span>Titel</span><br />
Dies ist eine Beschreibung
</div>
</div></div>
Quellcode CSS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
| body {
padding: 0;
margin: 0;
}
.container {
background-color: #c5e5e7;
height: 100vh;
width: 100vw;
display: flex;
align-items: center;
justify-content: space-around;
}
.wrapper {
perspective: 800px;
-webkit-perspective:800px;
}
.image {
height: 250px;
width: 250px;
border: 10px solid white;
position: relative;
}
.one {
background: url("rose500.jpg");
background-size: 250px;
}
.two {
background: url("generated-photos-child.jpg");
background-size: 250px 250px;
}
.caption {
background-color: white;
height: 80px;
width: 270px;
font-size: 20px;
color: #1f2c5b;
font-family: 'Montserrat', sans-serif;
box-sizing: border-box;
padding-left: 10px;
padding-top:2px;
transform-style: preserve-3d;
transform: rotateX(-180deg);
transform-origin: top;
z-index: -1;
position: relative;
transition: 1s;
backface-visibility: hidden;
}
.wrapper:hover .caption {
transform: rotateX(0deg);
} |
body {
padding: 0;
margin: 0;
}
.container {
background-color: #c5e5e7;
height: 100vh;
width: 100vw;
display: flex;
align-items: center;
justify-content: space-around;
}
.wrapper {
perspective: 800px;
-webkit-perspective:800px;
}
.image {
height: 250px;
width: 250px;
border: 10px solid white;
position: relative;
}
.one {
background: url("rose500.jpg");
background-size: 250px;
}
.two {
background: url("generated-photos-child.jpg");
background-size: 250px 250px;
}
.caption {
background-color: white;
height: 80px;
width: 270px;
font-size: 20px;
color: #1f2c5b;
font-family: 'Montserrat', sans-serif;
box-sizing: border-box;
padding-left: 10px;
padding-top:2px;
transform-style: preserve-3d;
transform: rotateX(-180deg);
transform-origin: top;
z-index: -1;
position: relative;
transition: 1s;
backface-visibility: hidden;
}
.wrapper:hover .caption {
transform: rotateX(0deg);
}
0 Kommentare