【原创视频】随机变logo背景图
思良:有网友想要这个功能,我就做个视频,并把代码提供出来!
1,添加放背景图的栏目,
2,隐藏该栏目
3,找背景图并且修改,大小最好是大于1600*400的
4,拷贝图片到网站里,或者直接上传,我以拷贝为例
5,发布文章 这里必须填写,图片路径
6,公共代码添加随机换背景的代码即可。
注意:此代码只适合本模版,如果用于你们的,请自行修改相关样式!
<!-- 思良:下面js可以让头部背景随机换(刷新就换),在指定栏目发图就自动添加一个, 第一个灵动得到专门发背景图的栏目(id为62)文章数 ,第二个循环得到指定栏目(62)文章的标题图片-->
<script language="JavaScript">
var how_many_ads =[e:loop={"select infos from [!db.pre!]enewsclass where classid=62",1,24,0}]<?=$bqr[infos]?>[/e:loop]
var now = new Date()
var sec = now.getSeconds()
var ad = sec % how_many_ads;
ad +=1;
[e:loop={62,130,0,0}]
if (ad==<?=$bqno?>){
banner="<?=$bqr['titlepic']?>";
}
[/e:loop]
document.write('<style type="text/css">');
document.write('#top-navigation2');
document.write('{background:url(')
document.write('' + banner + ') center bottom no-repeat; }');
document.write('</style>');
</script>