首先把图片放在img文件夹下的 ,img是放在MyEclipse的WebRoot里面的,否则路径可能不对。
(1):
1 2 3 4 5 6 7 8 |
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> </head> <body background="img/1.jpg"> </body> </html> |
(2):
1 2 3 4 5 6 7 8 9 10 11 |
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <style> .b{background-image:url(img/1.jpg)} </style> </head> <body Class="b"> </body> </html> |
还可以把css单独写,不管什么页面用的时候都可以用link调用那个css的名字就可以了。
如需转载,请注明文章出处和来源网址:http://www.divcss5.com/html/h57623.shtml