本文介绍了想要使宽度= 100%的幻灯片和图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 嘿,我想把幻灯片的宽度设为100%...当我写var slideWidth = 100%;它不起作用...请帮帮我 < script src = http://code.jquery.com/jquery-1.8.2.js type = text / javascript > < / script > < script 类型 = text / javascript > ; $(function(){ var currentPosition = 0; var slideWidth = 500; var slides = $('。slide'); var numberOfSlides = slides.length; setInterval(changePosition,3000); slides.wrapAll('< div id = slidesHolder > < / div > '); slides.css({'float':'left'}); $('#slidesHolder')。css('width',slideWidth * numberOfSlides); 函数changePosition(){ if(currentPosition == numberOfSlides - 1){ currentPosition = 0; } else { currentPosition ++; } moveSlide(); } 函数moveSlide(){ $('#slidesHolder')。animate({'marginLeft':slideWidth *( - currentPosition)}); } }); < / script > < style 类型 = text / css > #slideshow #slideshowWindow { width:500px; 身高:257像素; 保证金:0; 填充:0; 头寸:相对; 溢出:隐藏; } #slideshow #slideshowWindow .slide { margin:0; 填充:0; 宽度:500px; 身高:257像素; float:left; 头寸:相对; } < / style > < / head > < body > < div id = 幻灯片 > < div id = slideshowWindow > < div class = slide > < b > 欢迎使用Aspdotnet-Suresh.com SlideShow Image1 < / b > < img src = https://lh5.googleusercontent.com/-YRAs5XWsj3k/UROnzTJcTrI/AAAAAAAAD98/UIRWUOOwbsY/ s450 / SaveWater.jpg / > ; < / div > 解决方案 (function(){ var currentPosition = 0; var slideWidth = 500; var slides = ('。slide'); var numberOfSlides = slides.length; setInterval(changePosition,3000); slides.wrapAll('< div id = slidesHolder > < / div > '); slides.css({'float':'left'}); ('#slidesHolder')。css('width',slideWidth * numberOfSlides); 函数changePosition(){ if(currentPosition == numberOfSlides - 1){ currentPosition = 0; } else { currentPosition ++; } moveSlide(); } 函数moveSlide(){ hey guy i want to make a width of slide n image 100% ... when i write var slideWidth = 100%; it is not working ...please help me<script src="http://code.jquery.com/jquery-1.8.2.js" type="text/javascript"></script><script type="text/javascript">$(function () {var currentPosition = 0;var slideWidth = 500;var slides = $('.slide');var numberOfSlides = slides.length;setInterval(changePosition, 3000);slides.wrapAll('<div id="slidesHolder"></div>');slides.css({ 'float': 'left' });$('#slidesHolder').css('width', slideWidth * numberOfSlides);function changePosition() {if (currentPosition == numberOfSlides - 1) {currentPosition = 0;}else {currentPosition++;}moveSlide();}function moveSlide() {$('#slidesHolder').animate({ 'marginLeft': slideWidth * (-currentPosition) });}});</script><style type="text/css">#slideshow #slideshowWindow{width:500px;height:257px;margin:0;padding:0;position:relative;overflow:hidden;}#slideshow #slideshowWindow .slide{margin:0;padding:0;width:500px;height:257px;float:left;position:relative;}</style></head><body><div id="slideshow"><div id="slideshowWindow"><div class="slide"><b>Welcome to Aspdotnet-Suresh.com SlideShow Image1</b> <img src="https://lh5.googleusercontent.com/-YRAs5XWsj3k/UROnzTJcTrI/AAAAAAAAD98/UIRWUOOwbsY/s450/SaveWater.jpg" /> </div> 解决方案 (function () {var currentPosition = 0;var slideWidth = 500;var slides =('.slide');var numberOfSlides = slides.length;setInterval(changePosition, 3000);slides.wrapAll('<div id="slidesHolder"></div>');slides.css({ 'float': 'left' });('#slidesHolder').css('width', slideWidth * numberOfSlides);function changePosition() {if (currentPosition == numberOfSlides - 1) {currentPosition = 0;}else {currentPosition++;}moveSlide();}function moveSlide() { 这篇关于想要使宽度= 100%的幻灯片和图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-24 21:44