我的网站上有一个方框,其悬停动画类似于您在下面看到的内容。
我想知道是否可以实现这种效果,或者在第一次点击移动设备时类似的东西,第二次点击会将用户带到a-tag的目的地。
.container {
position: relative;
width: 50%;
}
.image {
display: block;
width: 100%;
height: auto;
}
.overlay {
position: absolute;
bottom: 0;
left: 0;
right: 0;
background-color: #008CBA;
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%;
transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
text-align: center;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<a href="#">>
<div class="container">
<img src="http://www.ptahai.com/wp-content/uploads/2016/06/Best-Reverse-Image-Search-Engines-Apps-And-Its-Uses-2016.jpg" alt="Avatar" class="image">
<div class="overlay">
<div class="text">Hello World</div>
</div>
</div>
</a>
</body>
</html>
答案 0 :(得分:0)
也许这可以帮到你,点击时调用CSS类,然后双击调用目标
<a href="#">
<div id="container" onclick="first()" ondbclick="doble()">
<img src="http://www.ptahai.com/wp-content/uploads/2016/06/Best-Reverse-Image-Search-Engines-Apps-And-Its-Uses-2016.jpg" alt="Avatar" class="image">
<div class="overlay">
<div class="text">Hello World</div>
</div>
JS:
function first(){
document.getElementById("container").className = "overlay";}
function doble(){
alert("here the href")}