我正在制作一个应用程序展示网站。我有一页全宽度垂直幻灯片。我在屏幕上加了一个固定电话。当用户使用按钮滑动手机时,我想在手机上添加一个图像。
当他按下按钮时,jquery将当前图像从电话中移除,并以滑动方式添加新图像。我找到了一个关于codyhouse https://codyhouse.co/demo/app-introduction-template/index.html#cd-product-tour的教程。
这是一个很好的教程,但不能做垂直的方式。我的幻灯片代码是
<div id="allslides">
<div id="1" class="slides" phone_image='its the url of the image going to be added on the phone when the slide is active '>
<h1>My Appp</h1>
<p class='content'>Some content</p>
</div>
<div id="2" class="slides" phone_image='its the url of the image going to be added on the phone when the slide is active '>
<h1>My Appp</h1>
<p class='content'>Some content</p>
</div>
<div id="3" class="slides" phone_image='its the url of the image going to be added on the phone when the slide is active '>
<h1>My Appp</h1>
<p class='content'>Some content</p>
</div>
<div id="4" class="slides" phone_image='its the url of the image going to be added on the phone when the slide is active '>
<h1>My Appp</h1>
<p class='content'>Some content</p>
</div>
</div>我给.slides的宽度和高度100%。滑块工作得很好,手机固定在屏幕上。但是我希望手机图像在每一张幻灯片上都有变化,它的效果应该和链接上的效果相同,但要以垂直方式。
我的导航按钮代码是
<div id="navigation">
<ul>
<li><a href="#" class="bullets" id="bullet1" onclick="slider(1)"></a></li>
<li><a href="#" class="bullets" id="bullet2" onclick="slider(2)"></a></li>
<li><a href="#" class="bullets" id="bullet3" onclick="slider(3)"></a></li>
<li><a href="#" class="bullets" id="bullet4" onclick="slider(4)"></a></li>
</ul>
</div>html的电话是这样的
<div class="phone">
<div class="cd-image-container">
<div>
<div class="cd-phone-frame"></div>
<div class="cd-image-wrapper">
</div>
</div>
</div>
</div>我使用的jQuery是
$(document).ready(function(){
$(".bullets").first().addClass('activeBullet');
var image = $("#1").attr('phone_image');
$('.cd-image-wrapper').prepend('<img src="'+image+'"data-video="video/video-2" alt="Screen Preview 2">');
setTimeout(function(){
$('.cd-image-wrapper img').slideDown("fast");
},1);
});
The slider function is this
function slider(n){
var ID = $(".activeDiv").attr("id");
var sid= ID.split("slide");
var new_id = sid[1];
if(new_id == n){
}else{
$(".slides").removeClass('activeDiv');
$("#slide"+n).addClass('activeDiv');
var top = $("#slide"+n).position().top;
$("#mainbar").css({'top':-top});
$(".bullets").removeClass('activeBullet');
$("#bullet"+n).addClass('activeBullet'); $('.cd-image-wrapper img').fadeOut("slow", function(){
var images = $("#"+id).attr('phone_image');
var div = $('<img src="'+images+'"data-video="video/video-2" alt="Screen Preview 2">').hide();
$(this).replaceWith(div);
$('.cd-image-wrapper img').fadeIn("slow");
});
}
} 正如你所看到的,我能够使手机图像改变效果以淡出和fadeIn的方式。有人能告诉我怎么用滑倒和滑动的方式吗?
发布于 2016-01-16 16:41:36
不太明白你的意思。我不能添加评论,所以就在这里写吧。
如果您的意思是要单击一个按钮和DIV幻灯片。您可以像animate.css一样使用css动画。
首先做好你想要的slideIn职位:绝对顶:100%;
你想要的slideOut职位是:绝对顶部:0;
然后单击按钮,将css动画类添加到slideIn分区,使其成为top:0,slideOut Div:-100%;它将工作,还可以添加其他动画,如更改其不透明度。
在这里使用css动画很容易-- 使用CSS动画
发布于 2016-01-16 16:32:07
https://stackoverflow.com/questions/34829050
复制相似问题