【发布时间】:2015-02-05 00:56:35
【问题描述】:
所以我有一个非常简单的 css 文件,它是基于使用 php 获取的 cookie 生成的。整个 css 也使用 php 显示,所以它
<?php header("Content-type: text/css");
$rand = $_COOKIE['randTopic'];
echo '
body {
margin-top: 50px;
margin-bottom: 50px;
background: none;
}
.full {
background: url("http://loremflickr.com/1920/1080/' . $rand . '") no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
';
?>
Loremflickr 只是一个从 flickr 给我随机图像的服务,我也可以选择我实际在做什么的主题。所以输出的 css 看起来就像这样:
body {
margin-top: 50px;
margin-bottom: 50px;
background: none;
}
.full {
background: url("http://loremflickr.com/1920/1080/wall
") no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
如您所见,有一个我并不真正想要的换行符,不知道为什么会出现在这里。我认为这可能会导致问题,你怎么看?
提前感谢您的帮助。
【问题讨论】:
-
如果您的 cookie 中有换行符,则会导致换行符,请仔细检查以确保您没有换行符。