如何将JPG图像设置为PHP文件的背景?

时间:2018-03-21 13:47:00

标签: php html

我想从与此页面背景相同的文件夹中设置JPG图像。谁能告诉我如何为这个页面做到这一点。我尝试将它添加到身体的开始但没有出现。

<?php 
 session_start();  
 if(isset($_SESSION["user"]))  
 {  
      header("location:home.php");  
 }  

 ?>
<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>SUNRISE ADMIN</title>
  <link rel="stylesheet" href="css/style.css"> 
</head>

<body>

<h3><a href="../index.html">SUNRISE HOMEPAGE</a></h3></div>

 <div class="container">

 <h2>Sunrise Admin Login</h2>
      <div id="login">

        <form method="post">

          <fieldset class="clearfix">

            <p><span class="fontawesome-user"></span><input type="text"  name="user" value="Username" onBlur="if(this.value == '') this.value = 'Username'" onFocus="if(this.value == 'Username') this.value = ''" required></p> <!-- JS because of IE support; better: placeholder="Username" -->
            <p><span class="fontawesome-lock"></span><input type="password" name="pass"  value="Password" onBlur="if(this.value == '') this.value = 'Password'" onFocus="if(this.value == 'Password') this.value = ''" required></p> <!-- JS because of IE support; better: placeholder="Password" -->
            <p><input type="submit" name="sub"  value="Login"></p>

          </fieldset>

        </form>



      </div> <!-- end login -->

    </div>

</body>
</html>

1 个答案:

答案 0 :(得分:0)

修改<body>

使用:<body style="background-image:url('/location/to/image.jpg');">

或者您可以将其添加到您的CSS样式表中

&#13;
&#13;
body {
        background-image:url('https://image.ibb.co/iXFDPc/Schermafbeelding_2015_06_11_om_11_50_14_grande_1.png');    
        background-repeat: no-repeat;
        background-attachment: fixed;
        background-position: center; 
    }
&#13;
<!DOCTYPE html>
<html>
<head>
	<title></title>
</head>
<body>

</body>
</html>
&#13;
&#13;
&#13;