gpt4 book ai didi

javascript - 需要 div 悬停然后在 ipad/iphone 上通过两次触摸转到其他页面

转载 作者:行者123 更新时间:2023-11-28 03:28:10 25 4
gpt4 key购买 nike

如果你能帮助我,我的悬停滚动 href 链接在 ipad/iphone 上遇到了触摸问题。

我希望我的框在 ipad 上第一次触摸时悬停在图像上,然后能够再次触摸以将用户转到另一个页面。目前链接不会显示。我正在努力想知道该怎么做。

HTML:

<!-- IMAGE CONTAINER -->
<div class="image-container">
<div class="image-container-overflow">
<div class="image-container-actual">
<div class="image">
<img src="http://www.placehold.it/188x188" />
<div class="hoverimg">
<a href="success.html">
<img class="fade" src="_includes/img/global/image2.jpg" width="188" height="188" />
<p>Helen was offered a job as a florist two weeks after she completed her Pinewood training. <br><br><strong>See Success Stories</strong></p>
</a>
</div>
</div>
<div class="image">
<img src="http://www.placehold.it/188x188" />
<div class="hoverimg">
<a href="success.html">
<img class="fade" src="_includes/img/global/image2.jpg" width="188" height="188" />
<p>Helen was offered a job as a florist two weeks after she completed her Pinewood training. <br><br><strong>See Success Stories</strong></p>
</a>
</div>
</div>
<div class="image">
<img src="http://www.placehold.it/188x188" />
<div class="hoverimg">
<a href="success.html">
<img class="fade" src="_includes/img/global/image2.jpg" width="188" height="188" />
<p>Helen was offered a job as a florist two weeks after she completed her Pinewood training. <br><br><strong>See Success Stories</strong></p>
</a>
</div>
</div>
<div class="image">
<img src="http://www.placehold.it/188x188" />
<div class="hoverimg">
<a href="success.html">
<img class="fade" src="_includes/img/global/image2.jpg" width="188" height="188" />
<p>Helen was offered a job as a florist two weeks after she completed her Pinewood training. <br><br><strong>See Success Stories</strong></p>
</a>
</div>
</div>
<div class="image">
<img src="http://www.placehold.it/188x188" />
<div class="hoverimg">
<a href="success.html">
<img class="fade" src="_includes/img/global/image2.jpg" width="188" height="188" />
<p>Helen was offered a job as a florist two weeks after she completed her Pinewood training. <br><br><strong>See Success Stories</strong></p>
</a>
</div>
</div>
<div class="image">
<img src="http://www.placehold.it/188x188" />
<div class="hoverimg">
<a href="success.html">
<img class="fade" src="_includes/img/global/image2.jpg" width="188" height="188" />
<p>Helen was offered a job as a florist two weeks after she completed her Pinewood training. <br><br><strong>See Success Stories</strong></p>
</a>
</div>
</div>
<div class="image">
<img src="http://www.placehold.it/188x188" />
<div class="hoverimg">
<a href="success.html">
<img class="fade" src="_includes/img/global/image2.jpg" width="188" height="188" />
<p>Helen was offered a job as a florist two weeks after she completed her Pinewood training. <br><br><strong>See Success Stories</strong></p>
</a>
</div>
</div>
<div class="image">
<img src="http://www.placehold.it/188x188" />
<div class="hoverimg">
<a href="success.html">
<img class="fade" src="_includes/img/global/image2.jpg" width="188" height="188" />
<p>Helen was offered a job as a florist two weeks after she completed her Pinewood training. <br><br><strong>See Success Stories</strong></p>
</a>
</div>
</div>
<div class="image">
<img src="http://www.placehold.it/188x188" />
<div class="hoverimg">
<a href="success.html">
<img class="fade" src="_includes/img/global/image2.jpg" width="188" height="188" />
<p>Helen was offered a job as a florist two weeks after she completed her Pinewood training. <br><br><strong>See Success Stories</strong></p>
</a>
</div>
</div>
<div class="image">
<img src="http://www.placehold.it/188x188" />
<div class="hoverimg">
<a href="success.html">
<img class="fade" src="_includes/img/global/image2.jpg" width="188" height="188" />
<p>Helen was offered a job as a florist two weeks after she completed her Pinewood training. <br><br><strong>See Success Stories</strong></p>
</a>
</div>
</div>
<div class="image">
<img src="http://www.placehold.it/188x188" />
<div class="hoverimg">
<a href="success.html">
<img class="fade" src="_includes/img/global/image2.jpg" width="188" height="188" />
<p>Helen was offered a job as a florist two weeks after she completed her Pinewood training. <br><br><strong>See Success Stories</strong></p>
</a>
</div>
</div>
<div class="image">
<img src="http://www.placehold.it/188x188" />
<div class="hoverimg">
<a href="success.html">
<img class="fade" src="_includes/img/global/image2.jpg" width="188" height="188" />
<p>Helen was offered a job as a florist two weeks after she completed her Pinewood training. <br><br><strong>See Success Stories</strong></p>
</a>
</div>
</div>
<div class="image">
<img src="http://www.placehold.it/188x188" />
<div class="hoverimg">
<a href="success.html">
<img class="fade" src="_includes/img/global/image2.jpg" width="188" height="188" />
<p>Helen was offered a job as a florist two weeks after she completed her Pinewood training. <br><br><strong>See Success Stories</strong></p>
</a>
</div>
</div>
<div class="image">
<img src="http://www.placehold.it/188x188" />
<div class="hoverimg">
<a href="success.html">
<img class="fade" src="_includes/img/global/image2.jpg" width="188" height="188" />
<p>Helen was offered a job as a florist two weeks after she completed her Pinewood training. <br><br><strong>See Success Stories</strong></p>
</a>
</div>
</div>
<div class="image">
<img src="http://www.placehold.it/188x188" />
<div class="hoverimg">
<a href="success.html">
<img class="fade" src="_includes/img/global/image2.jpg" width="188" height="188" />
<p>Helen was offered a job as a florist two weeks after she completed her Pinewood training. <br><br><strong>See Success Stories</strong></p>
</a>
</div>
</div>
</div>
</div>
</div>
<!-- IMAGE CONTAINER -->

CSS:-

/* Editable Multiple Image Area */
.image-container {
width: 100%;
margin: 0;
padding: 0;
height: 360px;
overflow: hidden;
}

.internal .image-container {
width: 100%;
margin: 0;
padding: 0;
height: 180px;
overflow: hidden;
}

.contact .image-container {
width: 100%;
margin: 0;
padding: 0;
height: 180px;
overflow: hidden;
}

.image-container-overflow {
width: 100%;
padding-right: 187px;
height: 360px;
position: relative;
}

.image-container-actual {
width: 100%;
height: 360px;
position: absolute;
top: 0;
left: 0;
}

.image {
position: relative;
float: left;
width: 188px;
height: 188px;
margin: 0;
padding: 0;
}

.image img {
position: absolute;
z-index: 1;
left: 0;
top: 0;
}

.image:hover div {
display: block!important;
}

.image img:hover div {
display: none;
position: absolute;
z-index: 2;
width: 100%;
height: 100%;
background: #f28f0a;
}

.hoverimg {
display: none;
position: absolute;
z-index: 2;
width: 100%;
height: 100%;
background: #f28f0a;
}

.hoverimg p {
font-family: 'ralewayregular';
color: #fff;
position: absolute;
z-index: 3;
font-weight: normal;
margin: 30px;
font-size: 12px;
letter-spacing: .5px;
line-height: 18px;
}

.fade {
opacity: 1;
transition: opacity .25s ease-in-out;
-moz-transition: opacity .25s ease-in-out;
-webkit-transition: opacity .25s ease-in-out;
}

.fade:hover {
opacity: 0.2;
}

这是 fiddle :- http://jsfiddle.net/m67k8/

如果有人有任何想法,我将不胜感激。

最佳答案

我会使用 JavaScript/JQuery 来做到这一点。无论悬停内容是否显示,点击(触摸)链接都需要采取不同的行动,所以我认为最快和最简单的方法是在 .hoverimg 打开时添加一个类,然后编写一个带有条件的函数来控制链接的行为是这样的:

$('.hoverimg a').click(function(e) {
if ( !$(this).parent('.hoverimg').hasClass('on') ) {
e.preventDefault();
$(this).parent('.hoverimg').addClass('on').css('display', 'block');
}
});

这是 fiddle :http://jsfiddle.net/m67k8/1/

关于javascript - 需要 div 悬停然后在 ipad/iphone 上通过两次触摸转到其他页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19745490/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com