Witam
Mam taki mały skrypcik płynnej rotacji obrazków.
Mam z nim problem nie mogę dojść co jest nie tak mianowicie działa prawidłowo pod każdą przeglądarką
firefox, opera, chrome, internet explorer 8, natomiast w internet explorer 7 się sypie.
Doszedłem że powodem tego jest następujący wpis
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
jeżeli go usunę to w IE7 działa ale problem w tym że powyższy skrypt chcę umieścić w serwisie w którym jest taki wpis i nie mogę się go pozbyć.
Proszę o pomoc.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript"> function wlewo()
{
var item_width = $('#carousel_ul li').outerWidth(true);
/* same as for sliding right except that it's current left indent + the item width (for the sliding right it's - item_width) */
var left_indent = parseInt($('#carousel_ul').css('left')) + item_width;
$('#carousel_ul:not(:animated)').animate({'left' : left_indent},1500,function(){
/* when sliding to left we are moving the last item before the first list item */
$('#carousel_ul li:first').before($('#carousel_ul li:last'));
/* and again, when we make that change we are setting the left indent of our unordered list to the default -130px */
$('#carousel_ul').css({'left' : '-130px'});
});
}
function wprawo()
{
//get the width of the items ( i like making the jquery part dynamic, so if you change the width in the css you won't have o change it here too ) '
var item_width = $('#carousel_ul li').outerWidth(true);
//calculae the new left indent of the unordered list
var left_indent = parseInt($('#carousel_ul').css('left')) - item_width;
//make the sliding effect using jquery's anumate function '
$('#carousel_ul:not(:animated)').animate({'left' : left_indent},1500,function(){
//get the first list item and put it after the last list item (that's how the infinite effects is made) '
$('#carousel_ul li:last').after($('#carousel_ul li:first'));
//and get the left indent to the default -130px
$('#carousel_ul').css({'left' : '-130px'});
});
}
$(document).ready(function() {
//move he last list item before the first item. The purpose of this is if the user clicks to slide left he will be able to see the last item.
$('#carousel_ul li:first').before($('#carousel_ul li:last'));
//when user clicks the image for sliding right
$('#right_scroll img').click(function(){
wprawo();
});
//when user clicks the image for sliding left
$('#left_scroll img').click(function(){
wlewo();
});
setInterval(function() {
wprawo();
}, 5000);
});
#carousel_inner {
float:left; /* important for inline positioning */
width:478px; /* important (this width = width of list item(including margin) * items shown */
height:130px;
overflow: hidden; /* important (hide the items outside the div) */
/* non-important styling bellow */
background: #d7cd85;
}
#carousel_ul {
position:relative;
left:-130px; /* important (this should be negative number of list items width(including margin) */
list-style-type: none; /* removing the default styling for unordered list items */
height:76px;
margin-left: 11px;
margin-top:0px;
padding: 0px;
width:9999px; /* important */
/* non-important styling bellow */
}
#carousel_ul li{
float: left; /* important for inline positioning of the list items */
width:116px; /* fixed width, important */
/* just styling bellow*/
padding:0px;
margin-top:10px;
margin-left:3px;
}
#carousel_ul li img {
.margin-bottom:-4px; /* IE is making a 4px gap bellow an image inside of an anchor (
<a href...>) so this is to fix that*/
/* styling */
cursor:pointer;
cursor: hand;
border:0px;
}
#left_scroll, #right_scroll{
float:right;
height:30px;
width:48px;
margin:0px;
}
#left_scroll img, #right_scroll img{
/*styling*/
cursor: pointer;
cursor: hand;
margin:0px;
}
<div id='carousel_container'>
<div id='carousel_inner'> <li><a href='#'><img src='item1.jpg' style="width:116px; height:76px" /></a></li> <li><a href='#'><img src='item2.jpg' style="width:116px; height:76px" /></a></li> <li><a href='#'><img src='item3.jpg' style="width:116px; height:76px" /></a></li> <li><a href='#'><img src='item4.jpg' style="width:116px; height:76px" /></a></li> <li><a href='#'><img src='item5.jpg' style="width:116px; height:76px" /></a></li> <li><a href='#'><img src='item6.jpg' style="width:116px; height:76px" /></a></li> <div id='right_scroll'><img src='prawo.jpg' /></div> <div id='left_scroll'><img src='lewo.jpg' /></div>