如何为PHP文件设置固定的背景图像? [英] How do I set a fixed background image for a PHP file?

查看:185
本文介绍了如何为PHP文件设置固定的背景图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有登录表单的.html文件,并且希望重新创建并将其保存为.php文件。但是,我在设置背景图像和其他CSS相关的东西方面遇到困难。

下面是我的.php代码,我相信它不会提供回答我的问题的指导,但我不知道从哪里开始。我检查过W3schools和其他许多网站。



一个很好的开始帮助我解决如何在.PHP文件中包含一个.CSS文件。也许给我一个快速的源代码示例。此外,设置固定背景
图片的代码将非常棒。

 <?php 

$ url ='C:\Users\George\Documents\HTML\bg.jpg';

?>

< html lang =en>
< head>

< title>这是一项测试< / title>

< style type =text / css>
body
{
background-image:url('<?php echo $ url?>');
}
< / style>

< / head>

< body>

< p>这是一项测试。< / p>

< / body>
< / html>


解决方案

我找到了我的答案。
$ b

 <?php 
$ profpic =bg.jpg;
?>

< html>
< head>
< style type =text / css>

ody {
background-image:url('<?php echo $ profpic;?>');
}
< / style>

< meta http-equiv =Content-Typecontent =text / html; charset = utf-8/>
< title>嘿< / title>
< / head>
< body>
< / body>
< / html>


I have an .html file with a login form and wish to recreate it and save it as a .php file. However, I'm encountering difficulties with setting the background image and other CSS related stuff.

Below is my code for the .php which I'm sure it won't provide guidance to answering my question, but I don't know where to start. I've checked W3schools and many other sites.

A great start to helping me out would on how I would include a .CSS file in .PHP file. Perhaps giving me the a quick source code example. Also, the code to set a fixed background image would be amazing.

<?php

$url = 'C:\Users\George\Documents\HTML\bg.jpg';

?>

<html lang="en">
<head>

<title>This is a test</title>

<style type="text/css">
body
{
background-image:url('<?php echo $url ?>');
}
</style>

</head>

<body>

<p>This is a test.</p>

</body>
</html>

解决方案

I found my answer.

<?php
$profpic = "bg.jpg";
?>

<html>
<head>
<style type="text/css">

body {
background-image: url('<?php echo $profpic;?>');
}
</style>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Hey</title>
</head>
<body>
</body>
</html>

这篇关于如何为PHP文件设置固定的背景图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆