wp 优化 / 网站建设

刷新主题页面更换背景图片

言七墨 · 11月29日 · 2019年 · 738次已读

教程:

将以下代言七墨码添加到 header.php 中的 https://qimok.cn</head&ghttps://qimok.cnt;言七墨 七墨博客上方即可:

< ?php { ? ><script type = "text/javascript" >
    //<!CDATA[
    var bodyBgs = [];
    bodyBgs[0] = "#page{background:url(https://cdn.qimok.cn/7a9633f2ce93034f29ce684984cca9ed%281%29.jpg);background-position:36% 33%;background-attachment: fixed;}@media screen and (max-width: 768px) {.style-vertical #top-part{background-position: 16% 28%;}}";
    bodyBgs[1] = "#page{background:url(https://cdn.qimok.cn/8eb8a5c5750e75c8aa4be978f4ad0731%281%29.jpg);background-position: 33%;background-attachment: fixed;}@media screen and (max-width: 768px) {.style-vertical #top-part{background-position: 63%;}}";
    bodyBgs[2] = "#page{background:url(https://cdn.qimok.cn/4099f865bb612479510a47751e987571%281%29.jpg);background-position: 99% 33%;background-attachment: fixed;}@media screen and (max-width: 768px) {.style-vertical #top-part{background-position: 85% 28%;}}";
    bodyBgs[3] = "#page{background:url(https://cdn.qimok.cn/72b23b9dea0337e63aa61ff347ac89ce%281%29.jpg);background-size: 1280px;background-attachment: fixed;}@media screen and (max-width: 768px) {.style-vertical #top-part{background-size: 1280px;background-position: 45% 2%;}}";
    bodyBgs[4] = "#page{background:url(https://cdn.qimok.cn/b9e4391de3aca57cecab3dd02fea59c6%281%29.jpg);background-position: 20% 0%;background-attachment: fixed;}@media screen and (max-width: 768px) {.style-vertical #top-part{background-position: 45% 2%;}}";
    var randomBgIndex = Math.round(Math.random() * 4);
    //输出随机的背景图[cunyanr.cn]
    document.write('<style>' + bodyBgs[randomBgIndex] + ' </style>');
    //]]>
    < /script>
<?php }?>/
0 条回应