简介
本次以随机图片API中的环境背景图片为例子,调用地址为:
https(推荐): https://img.xjh.me/random_img.php?type=bg&ctype=nature&return=302 http(更快,快一点点,不安全,可能会被劫持): http://img.xjh.me/random_img.php?type=bg&ctype=nature&return=302
如果需要人物背景图片,请把ctype的值由nature修改为acg,或留空,如:
https(推荐): https://img.xjh.me/random_img.php?type=bg&ctype=acg&return=302 http(更快,快一点点,不安全,可能会被劫持): http://img.xjh.me/random_img.php?type=bg&ctype=acg&return=302
使用方法
用法一:直接写入网页
直接在标签中添加
style="background-repeat:no-repeat; background-attachment:fixed;background-size:cover;background-image: url(https://img.xjh.me/random_img.php?type=bg&ctype=nature&return=302);"
此方法略微提升加载速度?(怀疑)
用法二:写入CSS样式文件
当要插入的标签含特定id时,使用: #id{background-repeat:no-repeat; background-attachment:fixed;background-size:cover;background-image: url(https://img.xjh.me/random_img.php?type=bg&ctype=nature&return=302);} 当要插入的标签含特定class时,使用 .class{background-repeat:no-repeat; background-attachment:fixed;background-size:cover;background-image: url(https://img.xjh.me/random_img.php?type=bg&ctype=nature&return=302);}
效果图:
请参考本站背景,如果没看到,请刷新浏览器缓存,Ctrl+F5,或使用开发者工具,屏蔽缓存。如果还没看到,那就请看下图:
那个,能把URL伪静态化的话,就很好了呢。
不然只能作为背景单一使用,而不能同时加载多张图片呢……
可以的啊,为啥不行,在最后面加个随机数
不行的原因是因为,你的URL中带了许多参数。
加了随机数会被当作参数识别,然后就返回错误代码了……
你自己试试?
不是让你直接在URL后面加数字啊笨,在后面加一对参数,×tamp=(一串随机数),这样加
你又没写出来!
不过我那主题没法用你的。URL结构不一样。
所以你这次纯属来踩场的?
我这是提意见(BUG)意见,你懂什么叫意见吗?
请问下 为什么我修改完后还是没变 修改以后保存按ctrl +f5 只会 出现在头部闪下就没了 修改完主题后台要设置么
content:"";
display:block;
position:absolute;
z-index:-1;
top:0;
left:0;
width:100%;
height:100%;
opacity:.5;
background-repeat:no-repeat;
background-size:cover;
background-attachment:fixed;
background-image: url(https://img.xjh.me/random_img.php?type=bg&ctype=nature&return=302);
}
这个是代码 如果在后面加上#kratos-blog-post{background:;} 则提示代码错误 expected rbrace at line 3482 col17
#kratos-page:after{
content:"";
display:block;
position:absolute;
z-index:-1;
top:0;
left:0;
width:100%;
height:100%;
opacity:.5;
background-repeat:no-repeat;
background-size:cover;
background-attachment:fixed;
background-image: url(https://img.xjh.me/random_img.php?type=bg&ctype=nature&return=302);
}
emmm.....我是在源码里面,直接把背景颜色的那段代码删掉的,错误没关系,忽略掉就行了
QAQ还是不行 我把style.css 中
.kratos-page-gray {
background: #f5f5f5
}
这个整段代码删了
缓存更新下还是一闪而过
http://blog.aillen.org/wp-content/themes/Kratos/style.css?ver=2.6 这个是我的css文件
你在后台->外观->主题设置->站点配置->背景颜色,这里去掉,也就是设置为空试试
额 现在背景这这块没问题了 然后页头和页尾还是没有变请问下要怎么设置。
页头:http://chuantu.biz/t6/327/1528692460x-1404775545.jpg
页尾:http://chuantu.biz/t6/327/1528692715x1822611377.jpg
兄弟,我怎么才能联系你,能加个QQ吗。有问题想请教。邮箱就是我QQ
不错,就是图片的质量有点点差
好厉害的api