我有一个交换图像和文本的jQuery滑块,我遇到的问题是在IE7及以下版本中我无法将幻灯片内容显示在图像上方。
示例(IE7):
(铬)
这是网站:http://new.dpwebdev.co.uk/business-sites/explore-d-and-d/index.php
我尝试更改图片和文字z-index
,但这不会影响IE7。有没有办法解决这个问题?
我也注意到箭头也丢失了。
编辑:
JSFIDDLE:http://jsfiddle.net/Ckde2/2/
代码:
HTML(部分):
<body id="home">
<!-- BEGIN CONTENT -->
<div id="content">
<!-- BEGIN CONTENT TOP SLIDESHOW -->
<div id="top-slide">
<div class="wrapper">
<!-- BEGIN CONTENT TOP SLIDESHOW SLIDES -->
<div id="slide0" class="slide" data:id="0">
<h2>Your Site... Defined</h2>
<h4>With D&D there is no inbetween, we will never compromise your requirements.</h4>
</div>
<div id="slide1" class="slide" data:id="1">
<h2>Your Site... Defined 2</h2>
<h4>With D&D there is no inbetween, we will never compromise your requirements.</h4>
</div>
<div id="slide2" class="slide" data:id="2">
<h2>Your Site... Defined 3</h2>
<h4>With D&D there is no inbetween, we will never compromise your requirements.</h4>
</div>
<!-- END CONTENT TOP SLIDESHOW SLIDES -->
</div>
<div id="slider-imgs">
<div id="s-img0" class="slide-imgs">
<img src="http://new.dpwebdev.co.uk/business-sites/explore-d-and-d/media/img/slider/img1-g.png" id="s-img0-g">
<img src="http://new.dpwebdev.co.uk/business-sites/explore-d-and-d/media/img/slider/img1-c.png" id="s-img0-c" class="color">
</div>
<div id="s-img1" class="slide-imgs">
<img src="http://new.dpwebdev.co.uk/business-sites/explore-d-and-d/media/img/staff/profiles/directors/dpassmore/g.png" id="s-img1-g">
<img src="http://new.dpwebdev.co.uk/business-sites/explore-d-and-d/media/img/staff/profiles/directors/dpassmore/c.png" id="s-img1-c" class="color">
</div>
<div id="s-img2" class="slide-imgs">
<img src="http://new.dpwebdev.co.uk/business-sites/explore-d-and-d/media/img/staff/profiles/directors/dpassmore/g.png" id="s-img2-g">
<img src="http://new.dpwebdev.co.uk/business-sites/explore-d-and-d/media/img/staff/profiles/directors/dpassmore/c.png" id="s-img2-c" class="color">
</div>
</div>
<div id="numSlides">3</div>
<div class="arrows">
<span class="arrow left"></span>
<span class="arrow right"></span>
</div>
<div id="select">
<div class="wrapper">
<div class="bullets"></div>
<div class="clear"></div>
</div>
</div>
</div>
<!-- END CONTENT TOP SLIDESHOW -->
</div>
</body>
JQUERY:
$(document).ready(function() {
//HOME.PHP
$('#home #top-slide').bind("mouseenter", function() {
$('#select').stop(true).fadeIn(600);
});
$('#home #top-slide').bind("mouseleave", function() {
$('#select').stop(true).fadeOut(600);
});
//HOME.PHP - SLIDER
function mainSlider() {
var numsliders;
var currentSlider = 0;
var interval;
var slideWidth;
var slideImgWidth;
var windowWidth = $(window).width();
$('#slider0').css('opacity', 1);
$(document).ready(function() {
numsliders = parseInt($('#numSlides').html());
generateBullets();
checkHover();
iefix();
$('#slide0').css('left', '0px');
$('#slide0').css('height', '300px');
$('#slide0').css('width', '1000px');
$('#slide0').css('top', '0px');
$('#slide0').css('opacity', '1');
$('#s-img0').css('opacity', '1');
$('#slide0').addClass("showing");
slideWidth = $('#slide0').width();
});
//arrow, bullet and autoplay functions
function nextSlider() {
specificSlider((currentSlider + 1) % numsliders);
}
function previousSlider() {
if (currentSlider !== 0) {
specificSlider((currentSlider - 1));
}
}
interval = window.setInterval(nextSlider, 7000);
function checkHover() {
$('#home #top-slide').bind("mouseenter", function() {
for (var b = 0; b < numsliders; b++) {
$(this).find(".slide-imgs img#s-img" + b + "-g").delay(300).fadeOut();
$(this).find(".slide-imgs img#s-img" + b + "-c").fadeIn(300);
};
});
$('#home #top-slide').bind("mouseleave", function() {
for (var d = 0; d < numsliders; d++) {
$(this).find(".slide-imgs img#s-img" + d + "-c").delay(300).fadeOut();
$(this).find(".slide-imgs img#s-img" + d + "-g").fadeIn(300);
};
});
};
function iefix() {
for (var ie = 0; ie < numsliders; ie++) {
$('#s-img' + ie).animate({
opacity: 0
}, 0, null);
};
};
function generateBullets() {
var $bullet = $('#select .bullets');
for (var i = 0; i < numsliders; i++) {
$bullet.append('<span class="bullet" id="' + i + '"></span>');
}
$('.bullets #0').addClass("selected");
}
//call arrow functions
$('span.arrow.left').click(function() {
previousSlider();
});
$('span.arrow.right').click(function() {
nextSlider();
});
//call bullet functions
$('body').on('click', '.bullet', function() {
var $id = $(this).attr("id");
specificSlider($id);
});
function specificSlider(sliderNumber) {
window.clearInterval(interval);
// move the next slider on deck
/*
$('#slide' + sliderNumber).css('left', $('#top-slide').css('width'));
$('#slide' + sliderNumber).css('top', '0px');
$('#slide' + sliderNumber).css('height', '300px');
$('#slide' + sliderNumber).css('width', '1000px');
*/
// move old slide off,
$('#slide' + currentSlider).animate({
left: '-1020px',
top: '0px',
height: '300px',
width: '1000px',
opacity: 0
}, 900, null);
$('#s-img' + currentSlider).animate({
opacity: 0
}, 900, null);
$('#slide' + currentSlider).removeClass("showing");
$('.bullets #' + currentSlider).removeClass("selected");
// new slide on
$('#slide' + sliderNumber).animate({
left: '0px',
height: '300px',
width: '1000px',
top: '0px',
opacity: 1
}, 900, null);
$('#s-img' + sliderNumber).animate({
opacity: 1
}, 900, null);
$('#slide' + sliderNumber).addClass("showing");
$('.bullets #' + sliderNumber).addClass("selected");
currentSlider = sliderNumber;
interval = window.setInterval(nextSlider, 7000);
}
}
//initalise slider
mainSlider();
});
CSS(部分):
/*============================================
ENABLE FONTS
============================================*/
@import url(http://fonts.googleapis.com/css?family=PT+Sans:400,700);
body {
font-family:"PT Sans";
font-size:13px;
}
html {
overflow-x:hidden;
overflow-y:scroll;
}
/*============================================
LINKS
============================================*/
a {
text-decoration:none;
color:#CCCCCC;
-moz-transition: color 150ms ease-out;
-webkit-transition: color 150ms ease-out;
}
/*============================================
LAYOUT
============================================*/
html, body {
width:100%;
height:100%;
margin:0;
padding:0;
}
.wrapper {
width:1000px;
margin:0 auto;
}
#header .wrapper, #footer .wrapper {
width:1100px;
}
.clear {
clear:both !important;
float:none !important;
}
/*============================================
CONTENT
============================================*/
#content {
min-height:100%;
margin-top:55px;
padding-top:10px;
}
/* IE FIX */
.ie7 #content {
padding-top:65px;
}
/*============================================
HOME.PHP
============================================*/
#home #content #top-slide {
background:#3D3B37 url(http://new.dpwebdev.co.uk/business-sites/explore-d-and-d/media/img/common/loaders/1.gif) no-repeat center;
height:300px;
position:relative;
color:#FFFFFF;
}
#home #content #top-slide .slide {
position:absolute;
opacity: 0;
left:-1000px;
background:#3D3B37;
}
#home #content #top-slide .wrapper {
position:relative;
}
#home #content #top-slide #numSlides{
visibility: hidden;
}
#home #content #top-slide h2, #home #content #top-slide h4 {
position:absolute;
margin:0;
z-index:9999;
display:block;
zoom:1;
}
#home #content #top-slide h2 {
margin:60px 0 0 0;
font-size:36px;
text-shadow: 0 1px 1px #1F1E1C;
}
#home #content #top-slide h4 {
margin:150px 0 0 0;
text-shadow: 0 1px 1px #1F1E1C;
}
#home #content #top-slide .arrows {
width:1100px;
margin:0 auto;
height:300px;
position:relative;
}
#home #content #top-slide .arrows span.arrow {
background:url(http://new.dpwebdev.co.uk/business-sites/explore-d-and-d/media/img/home/arrows.png) no-repeat;
display:block;
height:36px;
width:25px;
position:absolute;
top:40%;
cursor:pointer;
z-index:100;
zoom:1;
}
#home #content #top-slide .arrows span.arrow.left {
background-position:left;
left:0;
}
#home #content #top-slide .arrows span.arrow.right {
background-position:right;
right:0;
}
#home #content #top-slide #select {
height:48px;
width:100%;
position:absolute;
bottom:0;
background:url(http://new.dpwebdev.co.uk/business-sites/explore-d-and-d/media/img/home/bg-slie-select.png) repeat;
display:none;
line-height:48px;
z-index:10;
}
#home #content #top-slide #select span.bullet {
height:48px;
width:25px;
background:url(http://new.dpwebdev.co.uk/business-sites/explore-d-and-d/media/img/home/bullets.png) no-repeat right;
line-height:48px;
display:block;
float:left;
cursor:pointer;
}
#home #content #top-slide #select span.bullet:hover {
background-position:center;
}
#home #content #top-slide #select span.bullet.selected {
background-position:left;
}
#home #content #top-slide #slider-imgs .slide-imgs {
position:absolute;
width:100%;
height:300px;
opacity:0;
z-index:9 !important;
}
#home #content #top-slide #slider-imgs .slide-imgs img {
position:absolute;
right:0;
bottom:0;
display:block;
}
#home #content #top-slide #slider-imgs .slide-imgs img.color {
display:none;
}
#home #content #twitter-main {
background-color:#cccccc;
height:200px;
margin:10px 0;
padding-top:30px;
text-align:center;
}
#home #content #twitter-main i.icon-twitter {
background:url(http://new.dpwebdev.co.uk/business-sites/explore-d-and-d/media/img/common/social/twitter.png) no-repeat center;
width:37px;
height:37px;
margin:0px auto 20px auto;
display:block;
}
#home #content #twitter-main span.divider {
border-top:1px solid #535353;
height:0;
width:100px;
display:block;
margin:0 auto;
}
#home #content #twitter-main h2.feed {
margin:40px 0;
}
#home #content #twitter-main p.info {
font-size:10px;
color:#666666;
}
#home #content #services {
height:500px;
margin:0 0 10px 0;
background:#DDDDDD;
padding-top:20px;
}
#home #content #services .wrapper > h2{
margin-top:0px;
font-size:24px;
}
#home #content #services .cols .col {
margin:0 50px;
float:left;
width:233px;
text-align:center;
background:url(http://new.dpwebdev.co.uk/business-sites/explore-d-and-d/media/img/home/services-c-c.png) no-repeat top;
height:260px;
padding-top:170px;
}
#home #content #services .cols #ac.col {
background:url(http://new.dpwebdev.co.uk/business-sites/explore-d-and-d/media/img/home/services-c-ac.png) no-repeat top;
}
#home #content #services .cols #sup.col {
background:url(http://new.dpwebdev.co.uk/business-sites/explore-d-and-d/media/img/home/services-c-support.png) no-repeat top;
}
#home #content #services .cols #qu.col {
background:url(http://new.dpwebdev.co.uk/business-sites/explore-d-and-d/media/img/home/services-c-qu.png) no-repeat top;
}
#home #content #services .cols .col span.divider {
border-top:1px solid #3D3B37;
height:0;
width:100px;
display:block;
margin:0 auto;
}
答案 0 :(得分:1)
修正了!!通过更改包装器的CSS:
#home #content #top-slide .wrapper {
position:relative;
z-index:9998;
}
当我改变箭头的容器时也知道了:
#home #content #top-slide .arrows {
width:1100px;
margin:0 auto;
height:300px;
position:relative;
z-index:9998;
}