Css 背景图像,Tornado 提供图像
我在用tornado搭建一个图片服务器,代码是:
class Index(tornado.web.RequestHandler):
def get(self):
header = "image/png"
ifile = open("image.png","r")
self.add_header("Content-Type",header)
self.write(ifile.read())
我在网页上用这个图片,像这样:<img src="http://localhost:8888/img" />
,这样是没问题的。但是当我想在CSS的背景图片里用这个链接时,就不行了,比如:<div style="background-image:url(http://localhost:8888/img)"></div>
。
1 个回答
2
你的说法是对的,但是这个dev
的高度是0
,所以它没有显示出来。
<div style="background-image:url(http://localhost:8888/img); min-height: 100px; background-repeat: repeat;"> </div>