[英]Image Caption Hover Animation in html or/and css
I'm trying to make an image caption hover animation https://jsfiddle.net/6Lwo2231/ this is what I got. 我正在尝试制作图像标题悬停动画https://jsfiddle.net/6Lwo2231/这就是我得到的。
HTML: HTML:
<div class="container-a1">
<ul class="caption-style-1">
<li>
<img src="http://i68.tinypic.com/b8js6p.jpg" alt="" />
<div class="caption">
<div class="blur"></div>
<div class="caption-text">
<h1>Friends</h1>
<p>Whatever It Is - Always Awesome</p>
</div>
</div>
</li>
</ul>
</div>
CSS: CSS:
.caption-style-1{
list-style-type: none;
margin: 0px;
padding: 0px;
}
.caption-style-1 li{
float: left;
padding: 0px;
position: relative;
overflow: hidden;
}
.caption-style-1 li:hover .caption{
opacity: 1;
}
.caption-style-1 img{
margin: 0px;
padding: 0px;
float: left;
z-index: 4;
}
.caption-style-1 .caption{
cursor: pointer;
position: absolute;
opacity: 0;
-webkit-transition:all 0.45s ease-in-out;
-moz-transition:all 0.45s ease-in-out;
-o-transition:all 0.45s ease-in-out;
-ms-transition:all 0.45s ease-in-out;
transition:all 0.45s ease-in-out;
}
.caption-style-1 .blur{
background-color: rgba(0,0,0,0.65);
height: 300px;
width: 400px;
z-index: 5;
position: absolute;
}
.caption-style-1 .caption-text h1{
text-transform: uppercase;
font-size: 24px;
}
.caption-style-1 .caption-text{
z-index: 10;
color: #fff;
position: absolute;
width: 320px;
height: 240px;
text-align: center;
top:20px;
}
I am trying to make the caption visible even when not hovered by a mouse cursor, and when hover the image by a mouse cursor will move down the caption in the center and will show an arrow image to continue to a link page, just like this image shows. 我试图使标题即使不被鼠标光标悬停时仍可见,并且当鼠标悬停图像时,标题将在中心向下移动,并显示箭头图像以继续显示链接页面,就像这样图片显示。
Looking forward to your help. 期待您的帮助。 Thanks!
谢谢!
Here's my attempt. 这是我的尝试。 https://jsfiddle.net/6Lwo2231/3/
https://jsfiddle.net/6Lwo2231/3/
Just replace the arrow span with whatever arrow image you want. 只需将箭头范围替换为所需的任何箭头图像即可。
What i added. 我添加了什么。
HTML 的HTML
<div class="caption-text">
<h1>Friends</h1>
<p>Whatever It Is - Always Awesome</p>
<span class="arrow-link">ARROW IMG HERE</span>
</div>
CSS 的CSS
.caption-style-1 li:hover .blur{
opacity: 1;
}
.caption-style-1 li:hover .caption-text{
top:20px;
}
.caption-style-1 li:hover .arrow-link{
opacity: 1;
}
.caption-style-1 .caption-text{
z-index: 10;
color: #fff;
position: absolute;
width: 320px;
height: 240px;
text-align: center;
top:0px;
-webkit-transition:all 0.45s ease-in-out;
-moz-transition:all 0.45s ease-in-out;
-o-transition:all 0.45s ease-in-out;
-ms-transition:all 0.45s ease-in-out;
transition:all 0.45s ease-in-out;
}
.caption-style-1 .blur{
opacity: 0;
background-color: rgba(0,0,0,0.65);
height: 300px;
width: 400px;
z-index: 5;
position: absolute;
-webkit-transition:all 0.45s ease-in-out;
-moz-transition:all 0.45s ease-in-out;
-o-transition:all 0.45s ease-in-out;
-ms-transition:all 0.45s ease-in-out;
transition:all 0.45s ease-in-out;
}
EDIT: @tinkerbelts. 编辑:@tinkerbelts。 https://jsfiddle.net/6Lwo2231/5/
https://jsfiddle.net/6Lwo2231/5/
Your problem was this snippet 你的问题是这个片段
.caption-style-1 img{
margin: 0px;
padding: 0px;
float: left;
z-index: 4;
}
You're applying a left float to all images inside your caption, including the arrow. 您正在向字幕内的所有图像(包括箭头)应用左浮动。
Like this? 像这样? https://jsfiddle.net/6Lwo2231/2/
https://jsfiddle.net/6Lwo2231/2/
Basically you want to alter the position of .caption-text
, so you'll have to give this css selector a different position when the list item is hovered .caption-style-1 li:hover .caption-text
. 基本上,您想更改
.caption-text
的位置,因此,当列表项悬停在.caption-style-1 li:hover .caption-text
时,必须为该css选择器赋予不同的位置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.