Jquery刷新页面背景图片随机变换的实现方法
发布时间:2013-11-19 编辑:jiaochengji.com
Jquery刷新页面背景图片随机变换的实现方法,需要的朋友可以参考一下
使用方法:下载jquery-1.9.1.js,然后设置CSS,图片文件放在images/new_feed/目录下,图片命名格式为bg_x.jpg,修改随机数产生范围
一、CSS代码
复制代码 代码如下:
<style>
body{
padding:0;
background-attachment: fixed;
background-clip: border-box;
background-color: #666666;
background-origin: padding-box;
background-position: center top;
background-repeat: no-repeat;
background-size: cover;
width: 100%;
background-image:url("");}
</style>
二、Jquery代码
复制代码 代码如下:
<script type="text/javascript">
$(document).ready(function(){
var random_bg=Math.floor(Math.random()*6+1);
var bg='url(images/new_feed/bg_'+random_bg+'.jpg)';
$("body").css("background-image",bg);
});
</script>
您可能感兴趣的文章:
Jquery 随机刷新页面背景图片
Jquery刷新页面背景图片随机变换的实现方法
photoshop更换照片背景的方法
js操作css随机改变网页背景方法
photoshop利用虚化背景方法拯救废片教程
php点击验证码实时刷新的实现代码
用php生成带有雪花背景的验证码
php图片验证码的例子
photoshop制作出多彩马赛克背景图片教程
photoshop制作简洁的背景壁纸教程分享
[关闭]