我正在尝试使用jQuery循环来旋转页面上的一些图像。图像宽度为1400px,这意味着对于屏幕分辨率较小的用户来说,图像的右侧会消失。JavaScript - 根据浏览器窗口的大小移动图像
我想让图像在图像的任意一边都有相同的数量,因此图像的中心位于观察窗口的中心。
如果你看看http://renegadeox.com/并调整浏览器窗口大小,你会明白我的意思。
如何使用javascript将图像相对于容器左移并保持图像居中?
下面是完整的代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script type="text/javascript" src="http://malsup.github.com/jquery.cycle.all.js"></script>
</head>
<body>
<script type="text/javascript">
$(document).ready(function() {
$('.slideshowWrap').cycle({
fx: 'fade', // http://malsup.com/jquery/cycle/ Background rotater
});
});
</script>
<div style="margin: 0 auto" class="slideshowWrap">
<div class="homeslideshow">
<img src="background_01.jpg" alt="" />
</div>
<div class="homeslideshow">
<img src="background_02.jpg" alt="" />
</div>
<div class="homeslideshow">
<img src="background_03.jpg" alt="" />
</div>
</div>
</body>
</html>
嘿javiercf - 感谢输入。我已经放弃了它,但我无法完成它的工作。我并不是很了解JavaScript,但我明白这里会发生什么,但不幸的是,第一张图片淡出,然后没有任何内容。加上第一张图片并没有居中在页面中间的第一位:( –
我刚刚编辑了代码,你在哪里,没有工作,新的代码搞错了! – javiercf
你是个怪人天才男人!呜呼!!它的工作!非常感谢你。:) –