【发布时间】:2019-09-05 03:58:13
【问题描述】:
我正在尝试使用帮助 url 参数更改简单 php 页面的背景图像。我是新手,不太懂编码。
<img width="250" src="https://i.imgur.com/<?php echo $_GET['img']; ?>.png">
当我在 url 中使用上述代码时,我只需输入图片链接即可从 imgur.com 获取所需图片:
http://example.com/?img=frotzyG(全图网址:https://i.imgur.com/frotzyG.jpg)
但它只显示在一个 div 中,例如
<div class="abc">
<img width="250" src="https://i.imgur.com/<?php echo $_GET['img']; ?>.png">
</div>
现在我希望背景图像发生同样的事情。我有一个简单的 php 页面,它的背景图片源位于 css 中(例如 stylesheet.css)
这是 CSS 文件代码:
body {
background: url(images/bg.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
如何借助 url 参数(或任何你称之为的参数)更改背景图像。
附:对不起我的英语不好,希望你能理解我的意思。
【问题讨论】:
标签: php html css variables url-parameters