Permalink
Browse files

refactor: background in mobile 移动端背景优化

Use css color as background
in iPad and mobile (single column).

iPad 和 单栏模式时背景改用 CCS 颜色。
  • Loading branch information...
MOxFIVE committed Dec 27, 2015
1 parent 5db4784 commit febb9171ba0bb1f8efb05548733aa38324c6c518
Showing with 13 additions and 4 deletions.
  1. +13 −4 layout/_partial/background.ejs
@@ -1,9 +1,18 @@
<% if (theme.background_image){ %>
<script>
var backgroundnum = <%= theme.background_image %>;
var backgroundimg = "url(/background/bg-x.jpg)".replace(/x/gi, Math.ceil(Math.random() * backgroundnum));
$("body").css({"background": backgroundimg, "background-attachment": "fixed", "background-size": "cover"});
$(document).ready(function() {
var iPad = window.navigator.userAgent.indexOf('iPad');
if (iPad > -1 || $(".left-col").css("display") === "none") {
var bgColorList = ["#9db3f4", "#414141", "#e5a859", "#f5dfc6", "#c084a0", "#847e72", "#cd8390", "#996731"];
var bgColor = Math.ceil(Math.random() * (bgColorList.length - 1));
$("body").css({"background-color": bgColorList[bgColor], "background-size": "cover"});
}
else {
var backgroundnum = <%= theme.background_image %>;
var backgroundimg = "url(/background/bg-x.jpg)".replace(/x/gi, Math.ceil(Math.random() * backgroundnum));
$("body").css({"background": backgroundimg, "background-attachment": "fixed", "background-size": "cover"});
}
})
</script>
<% } else { %>
<style>

2 comments on commit febb917

@netcan

This comment has been minimized.

Show comment
Hide comment
@netcan

netcan Dec 29, 2015

CSS颜色。。写成了CCS

netcan replied Dec 29, 2015

CSS颜色。。写成了CCS

@MOxFIVE

This comment has been minimized.

Show comment
Hide comment
@MOxFIVE

MOxFIVE Dec 29, 2015

Owner

@netcan 睡太晚,意识模糊了。

Owner

MOxFIVE replied Dec 29, 2015

@netcan 睡太晚,意识模糊了。

Please sign in to comment.