我应该知道如何根据当天的情况进行背景更改(例如,在31日它转到万圣节图片然后在其他背景上转换到其他背景)PS我应该尝试不使用JavaScript因为我不喜欢使用JavaScript。
答案 0 :(得分:0)
您需要一个服务器端功能才能执行此操作。
例如
$date = date("d F");
if($date == "18 May"){
echo "style=\"background:rgba(0,0,0,1);\"" // don't forget to escape quotes and such
}
答案 1 :(得分:0)
在你的评论中,你说javascript没问题,所以这里是javascript。
这将为您完成:https://jsfiddle.net/4p18mxg9/5/
<强> JAVASCRIPT 强>
function myFunction() {
switch (new Date().getDay()) {
case 0:
day = "Sunday";
document.body.style.backgroundImage = "url('http://lorempixel.com/400/200/sports/1/')";
break;
case 1:
day = "Monday";
document.body.style.backgroundImage = "url('http://lorempixel.com/400/200/sports/1/')";
break;
case 2:
day = "Tuesday";
document.body.style.backgroundImage = "url('http://lorempixel.com/400/200/sports/1/')";
break;
case 3:
day = "Wednesday";
document.body.style.backgroundImage = "url('http://lorempixel.com/400/200/sports/1/')";
break;
case 4:
day = "Thursday";
document.body.style.backgroundImage = "url('http://lorempixel.com/400/200/sports/1/')";
break;
case 5:
day = "Friday";
document.body.style.backgroundImage = "url('http://lorempixel.com/400/200/sports/1/')";
break;
case 6:
day = "Saturday";
document.body.style.backgroundImage = "url('http://lorempixel.com/400/200/sports/1/')";
break;
}
document.getElementById("demo").innerHTML = "Today is " + day;
}