我想像HTML一样从CSS中更改CSS中的图像 [英] I want to change the image in CSS from HTML like a gallery

查看:79
本文介绍了我想像HTML一样从CSS中更改CSS中的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是html代码:



this is the html code :

<div class="Winter">

</div>





现在我还没有得到背景图片。





这是css代码:





right now i have not get background image.


this is the css code :

.Winter{
	background: no-repeat center bottom scroll;
	background-image:;	
	width:410px;
	height:410px;
	float:left;
	margin-top:20px;
	margin-left:5px;
}





i不设置backgourd图像,因为我在此用它来改变背景:



< script src =http://code.jquery.com/jquery-1.11.0.min.js>

$ (文件).ready(function(){

var Winter = $('body');



var backgrounds = new Array(

,'url(img / winter / earwarmers / 9.jpg)'

,'url(img / winter / hats / 7.jpg)'

,'url(img / winter / jacket / 4.jpg)'

);



var current = 0;



函数nextBackground(){

当前++;

current =当前%backgrounds.length;

Winter.css('background-image',背景[当前]);

}

setInterval(nextBackground,1000);



Winter.css('b ackground-image',背景[0]);

});

< / script>



现在我问这个:



i没有背景图片

但是我想要背景图片所以如何从html更改背景图片在css页面中它改变的页面?



我怎样才能在javascript或jquery中循环播放图像?



帮帮我PLZ



我尝试过:



i尝试将div类更改为id并按元素id设置get但是noyhing更改



i dont set a backgourd image because i use in this to change the background :

<script src="http://code.jquery.com/jquery-1.11.0.min.js">
$(document).ready(function(){
var Winter = $('body');

var backgrounds = new Array(
, 'url(img/winter/earwarmers/9.jpg)'
, 'url(img/winter/hats/7.jpg)'
, 'url(img/winter/jacket/4.jpg)'
);

var current = 0;

function nextBackground() {
current++;
current = current % backgrounds.length;
Winter.css('background-image', backgrounds[current]);
}
setInterval(nextBackground, 1000);

Winter.css('background-image', backgrounds[0]);
});
</script>

now i ask this :

i dont have background image
but i want background image so how can i change the background image from the html page that in the css page it change?

and how can i do that thr image go in loop in javascript or jquery?

help me plz

What I have tried:

i try to change the div class to id and set get by element id but noyhing change

推荐答案

(document).ready(function(){

var Winter =
(document).ready(function(){
var Winter =


('body');



var backgrounds = new Array(

,'url(img / winter / earwarmers / 9.jpg)'

,'url(img / winter / hats / 7.jpg)'

,'url(img / winter / jacket / 4.jpg)'

);



var current = 0;



函数nextBackground(){

当前++;

current = current%backgrounds.length;

Winter.css('background-image',背景[当前]);

}

setInterval(nextBackground,1000);



Winter.css('background-image',backgrounds [0]);

});

< ; / script>



现在我问这个:



i没有背景图片

,但我想要背景图片,那么如何更改css页面中更改的html页面中的背景图片呢?



我该怎么办? thr图像在javascript或jquery中循环播放?



帮助我PLZ



我是什么尝试过:



i尝试将div类更改为id并按元素id设置get但是noyhing更改
('body');

var backgrounds = new Array(
, 'url(img/winter/earwarmers/9.jpg)'
, 'url(img/winter/hats/7.jpg)'
, 'url(img/winter/jacket/4.jpg)'
);

var current = 0;

function nextBackground() {
current++;
current = current % backgrounds.length;
Winter.css('background-image', backgrounds[current]);
}
setInterval(nextBackground, 1000);

Winter.css('background-image', backgrounds[0]);
});
</script>

now i ask this :

i dont have background image
but i want background image so how can i change the background image from the html page that in the css page it change?

and how can i do that thr image go in loop in javascript or jquery?

help me plz

What I have tried:

i try to change the div class to id and set get by element id but noyhing change


这篇关于我想像HTML一样从CSS中更改CSS中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆