概述
刷新页面随机加载图片
<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>
</head>
<body>
<script src="./css/jquery-3.5.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var random_bg=Math.floor(Math.random()*3+1); //三张图轮换
var bg='url(./images/new_feed/bg_'+random_bg+'.jpg)';
$("body").css("background-image",bg);
});
</script>
图片放在images文件夹下new_feed文件夹中,命名以bg_(x),格式
最后
以上就是落后金毛为你收集整理的jq随机加载背景图的全部内容,希望文章能够帮你解决jq随机加载背景图所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复