简介
本次以随机图片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,或使用开发者工具,屏蔽缓存。如果还没看到,那就请看下图:
话不多说 支持!
非常不错!!!!
挺不错的。就是我这博客不太适合这种改背景。
左下角的妹子有点意思,
是吧,我也觉得有意思,就是突然说一些话猝不及防
想知道网站左下角的妹子怎么实现的大佬
文章已水,大佬请查阅
我喜欢你博客的那种,.......