- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个关于我的 slider 的问题。
我创建了这个DEMO来自代码笔。
在此演示中,您可以看到我有缩略图和大图像。当您将鼠标悬停在缩略图上时,大图像就会发生变化。
但我想添加自动播放。我的自动播放功能正常,但仅适用于缩略图,而不适用于大图像(它不会改变)。我可以做什么来解决这个问题?
jQuery(document).ready(function ($) {
function do_slide(){
interval = setInterval(function(){
moveRight();
}, 1000);
}
do_slide();
$('ul li').hover(function(){
clearInterval(interval);
});
$('ul li').mouseleave(function(){
do_slide();
});
var slideCount = $('#gallery ul li').length;
var slideWidth = $('#gallery ul li').width();
var slideHeight = $('#gallery ul li').height();
var sliderUlWidth = slideCount * slideWidth;
$('#gallery').css({ width: slideWidth, height: slideHeight });
$('#gallery ul').css({ width: sliderUlWidth, marginLeft: - slideWidth });
$('#gallery ul li:last-child').prependTo('#gallery ul');
function moveLeft() {
$('#gallery ul').animate({
left: + slideWidth
}, 100, function () {
$('#gallery ul li:last-child').prependTo('#gallery ul');
$('#gallery ul').css('left', '');
});
};
function moveRight() {
$('#gallery ul').animate({
left: - slideWidth
}, 100, function () {
$('#gallery ul li:first-child').appendTo('#gallery ul');
$('#gallery ul').css('left', '');
});
};
$('a.control_prev').click(function () {
moveLeft();
});
$('a.control_next').click(function () {
moveRight();
});
});
$(document).ready(function() {
$("#gallery li img").hover(function(){
$('#main-img').attr('src',$(this).attr('src').replace('thumb/', ''));
});
var imgSwap = [];
$("#gallery li img").each(function(){
imgUrl = this.src.replace('thumb/', '');
imgSwap.push(imgUrl);
});
$(imgSwap).preload();
});
$.fn.preload = function() {
this.each(function(){
$('<img/>')[0].src = this;
});
}
最佳答案
如果您替换 moveRight 函数:
function moveRight() {
$('#gallery ul').animate({
left: - slideWidth
}, 100, function () {
$('#gallery ul li:first-child').appendTo('#gallery ul');
$('#gallery ul').css('left', '');
});
};
与:
function moveRight() {
$('#gallery ul').animate({
left: - slideWidth
}, 100, function () {
var child = $('#gallery ul li:first-child');
$('#main-img').attr('src', $('img', child.next()).attr('src').replace('thumb/', ''));
child.appendTo('#gallery ul');
$('#gallery ul').css('left', '');
});
};
如果您正在寻找的话,这将使您的图库图像随缩略图一起移动?
关于javascript - 图像上的缩略图可通过 slider 更改更大的图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26384065/
我正在 Java 上开发 Tic Tac Toe 游戏(eclipse)。在我的计算机上,我的对话框非常小。我一直在努力把它做得更大。我没有任何运气。我希望这里有人能引导我走向正确的方向。下面的代码是
出于辅助功能的目的,我需要使所有可滚动控件(列表、 ListView )的滚动条更宽,滚动条箭头更大。 如何从可滚动控件(例如:TListView)获取滚动条( handle )? 如何使滚动条和箭头
在我的 flutter 应用程序中,我想制作一个圆圈作为这样的背景: 最佳答案 问题主要是当屏幕处于横向时,除非它覆盖整个屏幕,否则你不能在那里放置一个圆圈。 ClipRect 还有另一种方法,如果这
如何在列表中找到最接近的值,这将返回更高的值?示例:[3,7,12,19] 的列表,如果我的值为 8,我如何获得最接近(更大)的值 12?我想要 dart 中的这个逻辑。 最佳答案 只需过滤 List
我是一个绝对的 HTML 和 javascript 初学者,我很确定,这真的很容易实现。我生成了以下 IFRAME: document.write("");Das aktuelle Wetter in
我有点知道为什么压缩 DES 文件时它更大,但谁能给我正确的理由或链接,我似乎找不到任何原因? 谢谢:) 最佳答案 经过适当加密的密文在压缩程序看来非常像一系列随机数。如果没有以明文形式出现的模式,压
假设我有两个表,其中一个(我们称之为 person)有一个名为 type 的字段,该字段存储链接到另一个表的整数(我们称之为types 带有一个名为 id 的字段。什么会更能提高性能? 一个更大的查询
我有一个ListView,它使用GridView来显示DataTable,并且当新行添加到DataTable
我在只出现在 Firefox 中的导航菜单上遇到了一个奇怪的问题(在 IE7、8、9、10 和 Chrome 中工作正常)。菜单上的链接显示为 block ,但它们在 Firefox 中计算得比任何其
我正在使用 javax.mail 并获取邮件收件箱文件夹中的邮件计数。使用https://outlook.office.com/ Folder folderInbox = store.getFolde
我想让地球字形图标更大,以便它覆盖页面的大部分(它是矢量图像)。它不在按钮或任何东西中;它只是一个人。有没有办法做到这一点? 最佳答案 增加 glyphicon 的 font-size
我定制了一个看起来像这样的搜索栏 问题是很难捕获 slider 。所以我想做的是增加拇指的碰撞箱以使其更容易。我尝试了一些东西,但总是弄乱了搜索栏的外观。我有什么想法可以做到这一点吗? 布局.xml
我有一个问题:下载到 Documents 文件夹中的音乐比以前长 2 倍,而且体积更大。比特率也有问题(增加/减少 2 倍)。图片保存得很好,但任何音乐都有问题。也许我需要手动设置音频比特率,但我还没
为什么 div 区域仍然比图像 css 大? /image/WHDU3.jpg 如何设置 div 区域以适合图像? 最佳答案 IMG - 是行内元素,因此
我发现在对文本文件进行排序时非常困惑。不同的算法/应用程序会产生不同的结果,例如,比较两个字符串 str1=";P" 和 str2="-_-" 仅供引用,这里给出了这些字符串中每个字符的 ASCII:
我有一个应用程序已经在 Play 商店中存在多年,我刚刚构建了一个更新。该更新利用了 numberpicker,它的 min-sdk 为 11,并且在 v4 支持库中不适用。我倾向于发布我的新版本并在
你能告诉我如何强制 CSS 使 line-through 属性比元素 width 宽吗? 例如 50 结果看起来像现在如何使线条比元素更宽更明显? 赞 最佳答案 你可以使用 ,这是一种很俗气的方式 &
我想制作一个比应有的大得多的虚拟 Win32 EXE 文件。所以默认情况下,样板 Win32 EXE 文件为 80 KB。我想要一个 5 MB 的空间来测试其他一些实用程序。 第一个想法是添加资源,但
我有一个 UIView,里面有一个更大的 UIImageView。有没有办法隐藏超出 View 大小的内容? CGRect baseFrame = CGRectMake(100, 100, 300,
当我改变缓冲区的大小时,我得到了无法从 BufferedReader 解释的奇怪结果。 我曾强烈期望性能会随着缓冲区大小的增加而逐渐增加, yield 递减设置相当快,此后性能或多或少会持平。但看起来
我是一名优秀的程序员,十分优秀!