客服QQ 2861666504

php随机调用百度背景图片,如何在网页中调用岁月小筑随机图片API

日记 我是谁 6个月前 (11-22) 100次浏览 扫描二维码

简介

本次以随机图片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,或使用开发者工具,屏蔽缓存。如果还没看到,那就请看下图:

http://maxiaos.top/2.html

喜欢 (0)
联系客服
联系客服
热线电话