从背景图像下方过渡文本
Transition text from below a background image
问题:
我不知道如何在每个人的头像
中制作漂亮的 hover/transition
当有人将鼠标悬停在图片圈上时,我想从下方 appear/slide 获取此人的其他信息。
https://i.imgur.com/FMEVDx9.jpg
我正在制作一个关于我们的页面作为学校项目。一直在考虑可能是一些 z-index 欺骗或不透明。
.container {
position: relative;
width: 50%;
}
.image {
display: block;
width: 100%;
height: auto;
border-radius: 50%;
}
.overlay {
position: absolute;
bottom: 0;
left: 0;
right: 0;
overflow: hidden;
width: 100%;
height: 0;
transition: .5s ease;
}
.container:hover .overlay {
height: 100%;
}
.text {
color: white;
font-size: 20px;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
text-align: center;
}
<body>
<p>Hover over the image to see the effect.</p>
<div class="container">
<img src="https://upload.wikimedia.org/wikipedia/en/thumb/1/17/Batman-BenAffleck.jpg/200px-Batman-BenAffleck.jpg" alt="Avatar" class="image">
<div class="overlay">
<div class="text">Hi I'm Batman</div>
</div>
</div>
</body>
</html>
Try the following. I guess this is what you are looking for. I made use of pure css for this. On hover, the text rises from the bottom. I made use of an overlay class and I made use of image border-radius to get the rounded shape you were looking for.
您可以阅读有关这些技巧的更多信息here.
问题: 我不知道如何在每个人的头像
中制作漂亮的hover/transition
当有人将鼠标悬停在图片圈上时,我想从下方 appear/slide 获取此人的其他信息。
https://i.imgur.com/FMEVDx9.jpg
我正在制作一个关于我们的页面作为学校项目。一直在考虑可能是一些 z-index 欺骗或不透明。
.container {
position: relative;
width: 50%;
}
.image {
display: block;
width: 100%;
height: auto;
border-radius: 50%;
}
.overlay {
position: absolute;
bottom: 0;
left: 0;
right: 0;
overflow: hidden;
width: 100%;
height: 0;
transition: .5s ease;
}
.container:hover .overlay {
height: 100%;
}
.text {
color: white;
font-size: 20px;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
text-align: center;
}
<body>
<p>Hover over the image to see the effect.</p>
<div class="container">
<img src="https://upload.wikimedia.org/wikipedia/en/thumb/1/17/Batman-BenAffleck.jpg/200px-Batman-BenAffleck.jpg" alt="Avatar" class="image">
<div class="overlay">
<div class="text">Hi I'm Batman</div>
</div>
</div>
</body>
</html>
Try the following. I guess this is what you are looking for. I made use of pure css for this. On hover, the text rises from the bottom. I made use of an overlay class and I made use of image border-radius to get the rounded shape you were looking for.
您可以阅读有关这些技巧的更多信息here.