好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

php怎么把图片设为背景

我们可以在php中 输出样式代码,达到改变html背景图片的目的。

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<!-- 通过设置style实现改变背景 -->
<body <?php echo 'style="background:url(图片.jpg);"'; ?> >
<form action="DataBase.php" method="post">
用户名:<input type="text" name="username" maxlength="40"/><br/>
密码:<input type="password" name="pwd" maxlength="40"/><br/>
<input type="submit" value="提交"/>
</form>
</body>
</body>
</html> 

但是并不建议在php代码中 输出样式文件,应该在html文档中书写,或单独写css样式文件,在html中引入。

1、在html中写css

<!-- 在head标签内书写css -->
<style>
body{background:url(背景图片地址);}
</style> 

2、引入css文件

//main.css文件
body{background:url(背景图片地址);}

//在html文件head标签中引入
<link rel="stylesheet" href="main.css"> 

更多PHP相关知识,请访问PHP中文网!

以上就是php怎么把图片设为背景的详细内容,更多请关注Gxl网其它相关文章!

查看更多关于php怎么把图片设为背景的详细内容...

  阅读:48次