PHP / CSS根据运行会话更改背景图像

时间:2013-11-26 20:41:39

标签: php css stylesheet

我根据我所在的区域更改背景图片时遇到问题。 如果我在浏览器中打开文件,它看起来像这样:background-image:url('CHRISTIAN / images / forest.jpg');

<?php
session_start();

header("Content-type: text/css");

if($_SESSION['in_area']==false){
$backgroundimage = "url('CHRISTIAN/images/background.jpg')";
} else if($_SESSION['in_area']=="forest"){
$backgroundimage = "url('CHRISTIAN/images/forest.jpg')";
  } else if($_SESSION['in_area']=="graveyard"){
      $backgroundimage = "url('CHRISTIAN/images/graveyard.jpg')";
   }
?>

body {
    background-image: <?= $backgroundimage ?>;
    background-repeat: no-repeat;
    background-attachment:fixed;
    -webkit-background-size: 2000px 1200px;
}

同一样式表中的一些工作代码:

$playerhealth = $_SESSION['hero_health_percentage']; 
$white = '#fff';
$dkgray = '#333';
$dkgreen = '#008400';
?>


#playerhpbar {
float: left;
width: 200px;
height: 20px;
border: 1px solid black;
background:<?= $dkgray ?>;
color:<?= $white ?>;
}

#playerhpbarcurrent {
float:left;
width: <?= $playerhealth ?>%;
height: 100%;
background-color:<?= $dkgreen ?>;
}

0 个答案:

没有答案