简介
本次以随机图片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,或使用开发者工具,屏蔽缓存。如果还没看到,那就请看下图:
图片都是网络爬取还是自己准备了一切的
原图片自己在P站看到喜欢就右键的,然后用Python筛选尺寸,再用工具压缩图片
咦,10月26日的帖子有半个月前的评论
那个是文章修改日期
不错,学习了
速度蛮不错的,响应很快。也可以弄个分类,针对不同风格的图片分开调用。[机智.gif]
大学生哪来那么多时间折腾啊
大佬什么时候改了模板,都没发现
都改了几个月了
加了
加了,不过我的是随机出现的,因为数量太多了
老哥 我就想知道网站左边的人物怎么实现的