【发布时间】:2013-04-19 05:32:56
【问题描述】:
我创建的网站在桌面上运行良好,但在 iPhone 和 iPad 上不显示背景图像。
我尝试删除选择图像的 php 脚本并重新编写代码以使用 javascript 设置背景,在这种情况下背景显示正确。
这是选择图像的 php 代码:
<?php
//if doesn't exist, open the session
if(!isset($_SESSION))
{
session_start();
}
//set coockie
setcookie("allweb","connected", time()+3600);
//if doesn' exist yet, I create a new array
if(!isset($_SESSION['arrayImage'])){
$arrayImage = array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
}else{// else I get from sessiom
$arrayImage = $_SESSION['arrayImage'];
}
//if already exist variable $picture, increment it
if(isset($_SESSION['picture']) && isset($arrayImage)){
$picture=$_SESSION['picture'];
$picture = $picture + 1;
$_SESSION['picture'] = $picture;//save picture
}else{// else I create it
$picture = 1;
$_SESSION['picture'] = $picture;// save it
shuffle($arrayImage);// I shuffle the array
$_SESSION['arrayImage'] = $arrayImage;//save array to the session
}
?>
在 php 页面中,我在样式标签之间有这段代码:
<style type="text/css">
<?php
if($picture < 15){//if I'm not out fo bound I continue
echo 'body {background-image:url("images/bg'.$arrayImage[$picture].'hq.jpg");}';
}
else{// else I set picture to default value and restar the loop.
$picture = 0;
$_SESSION['picture'] = $picture;// save it
echo 'body {background-image:url("images/bg'.$arrayImage[$picture].'hq.jpg");}';
}
?>
</style>
问题是图像没有立即显示,但我必须缩放页面才能显示。
【问题讨论】:
-
嗨,马丁,请在Stack Overflow问答中编辑您的姓名和工作单位。我可能会进来喝杯咖啡,因为我住在这条路上但我们不会在 Stack Overflow 做广告 - 如果我们这样做,则必须有免责声明。祝你好运!